This section contains the different types of EVM methods that can be used in the Unity SDK. For additional operations and methods please refer to the ChainSafe Documentation.
PlayerPrefs.GetString("Account") is the user's wallet account accessed after the LoginScene.
Copy string account = PlayerPrefs.GetString("Account");
print(account);
Important: If you run your script from the editor, you will have to hardcode the account string (e.g. "0x6e...")
Copy string chain = "cronos";
string network = "mainnet"; // mainnet or testnet
int blockNumber = await EVM.BlockNumber(chain, network);
print(blockNumber); Some code
Copy string chain = "cronos";
string network = "mainnet"; // mainnet or testnet
string account = "WALLET_ADDRESS";
string balance = await EVM.BalanceOf(chain, network, account, rpc);
print(balance);
Verify a signed message.
Copy string message = "YOUR_MESSAGE";
string signature = "YOUR_SIGNATURE";
string address = await EVM.Verify(message, signature);
print(address);
Print Nonce.
Copy string chain = "cronos";
string network = "mainnet"; // mainnet or testnet
string account = "WALLET_ADDRESS";
string rpc = "https://evm-dev.cronos.org";
string nonce = await EVM.Nonce(chain, network, account, rpc);
print(nonce);
Convert WEI to CRO and CRO to WEI
Copy float cro = float.Parse("0.1");
float decimals = 1000000000000000000; // 18 decimals
float wei = cro * decimals;
print(Convert.ToDecimal(wei).ToString());
float wei = float.Parse("10123755");
float decimals = 1000000000000000000; // 18 decimals
float cro = wei / decimals;
print(Convert.ToDecimal(cro).ToString());