Intermediate
How to integrate the contracts using ERC1155, ERC721 and ERC721 with Unity SDK
This tutorial provides an overview of the ERC1155 standard interface for contracts that manage multiple token types. The ERC1155 standard allows a single deployed contract to include any combination of fungible tokens, non-fungible tokens or other configurations. The tutorial covers different ERC1155 methods that can be used in the Unity SDK, including Balance Of, Balance Of Batch, URI, and All 1155s. Additionally, the tutorial provides information on the ERC721 and ERC20 standards, which provide standard interfaces for non-fungible tokens and tokens, respectively. For each standard, the tutorial covers different methods such as Balance Of, Owner Of, URI, and All.
ERC1155
A standard interface for contracts that manage multiple token types. A single deployed contract may include any combination of fungible tokens, non-fungible tokens or other configurations
This section contains the different types of ERC1155 methods that can be used in the Unity SDK. For additional operations and methods please refer to the ChainSafe Documentation.
Balance Of
Counts all ERC1155 tokens assigned to an owner
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string account = "WALLET_ADDRESS"; string tokenId = "TOKEN_ID"; BigInteger balanceOf = await ERC1155.BalanceOf(chain, network, contract, account, tokenId); print(balanceOf);
Balance Of Batch
Balance of batch will get the balance of a list of accounts and token ids
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string[] accounts = { "WALLET_ADDRESS", "WALLET_ADDRESS" }; string[] tokenIds = { "TOKEN_ID", "TOKEN_ID" }; List<BigInteger> batchBalances = await ERC1155.BalanceOfBatch(chain, network, contract, accounts, tokenIds); foreach (var balance in batchBalances) { print ("BalanceOfBatch: " + balance); }
URI
Returns meta data about the token.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string tokenId = "TOKEN_ID"; string uri = await ERC1155.URI(chain, network, contract, tokenId); print(uri);
All 1155s
Get all 1155 tokens from an account.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string account = "WALLET_ADDRESS"; string contract = "CONTRACT_ADDRESS"; int first = 500; int skip = 0; string response = await EVM.AllErc1155(chain, network, account, contract, first, skip); print(response);
ERC721
A standard interface for non-fungible tokens
This section contains the different types of ERC721 methods that can be used in the Unity SDK. For additional operations and methods please refer to the ChainSafe Documentation.
Balance Of
Counts all ERC721 tokens assigned to an owner
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string account = "WALLET_ADDRESS"; int balance = await ERC721.BalanceOf(chain, network, contract, account); print(balance);
Owner Of
Find the owner of an ERC721 token
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string tokenId = "TOKEN_ID"; string ownerOf = await ERC721.OwnerOf(chain, network, contract, tokenId); print(ownerOf);
Owner Of Batch
Balance of batch will get the balance of a list of token ids
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string[] tokenIds = {"TOKEN_ID", "TOKEN_ID"}; List<string> batchOwners = await ERC721.OwnerOfBatch(chain, network, contract, tokenIds); foreach (string owner in batchOwners) { print ("OwnerOfBatch: " + owner); }
URI
Returns meta data about the token.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string tokenId = "TOKEN_ID"; string uri = await ERC721.URI(chain, network, contract, tokenId); print(uri)
All 721s
Get all 721 tokens from an account
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string account = "WALLET_ADDRESS"; string contract = ""; int first = 500; int skip = 0; string response = await EVM.AllErc721(chain, network, account, contract, first, skip); print(response);
ERC20
A standard interface for tokens.
This section contains the different types of ERC20 methods that can be used in the Unity SDK. For additional operations and methods please refer to the ChainSafe Documentation.
Balance Of
Counts all ERC721 tokens assigned to an owner
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string account = "WALLET_ADDRESS"; BigInteger balanceOf = await ERC20.BalanceOf(chain, network, contract, account); print(balanceOf);
Name
Returns the name of the token.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string name = await ERC20.Name(chain, network, contract); print(name);
Symbol
Returns the symbol of the token
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; string symbol = await ERC20.Symbol(chain, network, contract); print(symbol);
Decimals
Returns the number of decimals the token uses – e.g. 8, means to divide the token amount by 100000000 to get its user representation.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; BigInteger decimals = await ERC20.Decimals(chain, network, contract); print(decimals);
Total Supply
Returns the total token supply.
string chain = "cronos"; string network = "mainnet"; // mainnet or testnet string contract = "CONTRACT_ADDRESS"; BigInteger totalSupply = await ERC20.TotalSupply(chain, network, contract); print(totalSupply);