Custom RPC
A standard interface for custom RPC methods.
This section contains an introduction to custom methods that can be used in the Unity SDK. For additional operations and methods please refer to the ChainSafe Documentation.
Example of Custom RPC
Connect to Cronos and any EVM compatible blockchain by providing an RPC. All methods have an optional field to add an RPC URL.
string chain = "cronos";
string network = "mainnet"; // mainnet or testnet
string account = "WALLET_ADDRESS";
string rpc = "https://evm-dev.cronos.org"; // test: https://evm-dev-t3.cronos.org/
string balance = await EVM.BalanceOf(chain, network, account, rpc);
print(balance);Call Custom Contracts
Call will execute a smart contract method without altering the smart contract state.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract AddTotal {
uint256 public myTotal = 0;
function addTotal(uint8 _myArg) public {
myTotal = myTotal + _myArg;
}
}lidLast updated
Was this helpful?