Actions
Modal Actions
Open Modal
// Open default view
AppKit.OpenModal();
// Open network selection view
AppKit.OpenModal(ViewType.NetworkSearch);
// Open account view
AppKit.OpenModal(ViewType.Account);
Close Modal
AppKit.CloseModal();
Chain Actions
Set active chain
Note: The chain must be added to the list of supported chains in the AppKit configuration.
Chain newChain = ChainConstants.Chains.Ethereum;
await AppKit.NetworkController.ChangeActiveChainAsync(newChain);
Get active chain
Chain activeChain = AppKit.NetworkController.ActiveChain;
Account Actions
Get active account
// Get active account in CAIP-10 format
Account account = AppKit.GetAccountAsync();
Debug.Log(account.Address); // e.g. '0x12345...'
Debug.Log(account.ChainId); // e.g. 'eip155:1'
Debug.Log(account.AccountId); // e.g. 'eip155:1:0x12345...'
Disconnect
await AppKit.DisconnectAsync();
EVM Actions
Get Balance
Get the native token balance for an address.
BigInteger balance = await AppKit.EVM.GetBalanceAsync("0x123...");
Sign Message
Sign a message with the active account's private key.
// Sign a string message
string signature = await AppKit.EVM.SignMessageAsync("Hello World");
// Sign raw bytes
byte[] rawMessage = System.Text.Encoding.UTF8.GetBytes("Hello World");
string signature = await AppKit.EVM.SignMessageAsync(rawMessage);
// Sign with specific address (optional)
string signature = await AppKit.EVM.SignMessageAsync("Hello World", "0x123...");
Sign Typed Data
Sign typed data following EIP-712 standard.
string typedData = "{ /* Your EIP-712 typed data structure */ }";
string signature = await AppKit.EVM.SignTypedDataAsync(typedData);
Verify Message Signature
Verify if a message was signed by a specific address.
// Basic verification
bool isValid = await AppKit.EVM.VerifyMessageSignatureAsync(
"0x123...", // address
"Hello World", // original message
"0xabc..." // signature
);
// Using parameters object
var verifyMessageParams = new VerifyMessageSignatureParams
{
Address = "0x123...",
Message = "Hello World",
Signature = "0xabc..."
};
bool isValid = await AppKit.EVM.VerifyMessageSignatureAsync(verifyMessageParams);
Verify Typed Data Signature
Verify if typed data was signed by a specific address.
// Basic verification
bool isValid = await AppKit.EVM.VerifyTypedDataSignatureAsync(
"0x123...", // address
"{ /* Your typed data */ }", // original typed data
"0xabc..." // signature
);
// Using parameters object
var verifyTypedDataParams = new VerifyTypedDataSignatureParams
{
Address = "0x123...",
Data = "{ /* Your typed data */ }",
Signature = "0xabc..."
};
bool isValid = await AppKit.EVM.VerifyTypedDataSignatureAsync(verifyTypedDataParams);
Read Contract
Read data from a smart contract (no gas required).
Note: Both JSON and human-readable ABI formats are supported. Human-readable ABI is more concise but JSON ABI may offer better performance.
// Using JSON ABI
string jsonAbi = "[ /* Your contract ABI */ ]";
string tokenSymbol = await AppKit.EVM.ReadContractAsync<string>(
"0x123...", // contract address
jsonAbi,
"symbol" // method name
);
// Using human-readable ABI
string humanReadableAbi = "function symbol() view returns (string)";
string tokenSymbol = await AppKit.EVM.ReadContractAsync<string>(
"0x123...", // contract address
humanReadableAbi,
"symbol" // method name
);
// With arguments
string balance = await AppKit.EVM.ReadContractAsync<string>(
"0x123...", // contract address
jsonAbi,
"balanceOf", // method name
new object[] { "0x456..." } // arguments
);
// Using parameters object
var readContractParams = new ReadContractParams
{
ContractAddress = "0x123...",
ContractAbi = jsonAbi,
MethodName = "balanceOf",
Arguments = new object[] { "0x456..." }
};
string balance = await AppKit.EVM.ReadContractAsync<string>(readContractParams);
Write Contract
Write data to a smart contract (requires gas).
Note: Both JSON and human-readable ABI formats are supported.
string contractAbi = "[ /* Your contract ABI */ ]";
// Or use human-readable ABI: "function transfer(address to, uint256 amount) returns (bool)"
// Basic write
string txHash = await AppKit.EVM.WriteContractAsync(
"0x123...", // contract address
contractAbi,
"transfer", // method name
"0x456...", // recipient
1000 // amount
);
// Write with custom gas
string txHash = await AppKit.EVM.WriteContractAsync(
"0x123...", // contract address
contractAbi,
"transfer", // method name
gas: 100000, // custom gas limit
"0x456...", // recipient
1000 // amount
);
// Write with value and gas
string txHash = await AppKit.EVM.WriteContractAsync(
"0x123...", // contract address
contractAbi,
"stake", // method name
value: 1000000000000000000, // 1 ETH in wei
gas: 100000,
true // other arguments
);
// Using parameters object
var writeContractParams = new WriteContractParams
{
ContractAddress = "0x123...",
ContractAbi = contractAbi,
MethodName = "transfer",
Value = 0, // optional value in wei
Gas = 100000, // optional gas limit
Arguments = new object[] { "0x456...", 1000 }
};
string txHash = await AppKit.EVM.WriteContractAsync(writeContractParams);
Send Transaction
Send a native token transaction.
// Basic transaction
string txHash = await AppKit.EVM.SendTransactionAsync(
"0x123...", // recipient address
1000000000000000000, // 1 ETH in wei
"0x" // optional data
);
// Using parameters object
var transactionParams = new SendTransactionParams
{
AddressTo = "0x123...",
Value = 1000000000000000000, // 1 ETH in wei
Data = "0x" // optional data
};
string txHash = await AppKit.EVM.SendTransactionAsync(transactionParams);
Send Raw Transaction
Send a pre-signed transaction.
string txHash = await AppKit.EVM.SendRawTransactionAsync(
"0x123..." // signed transaction data
);
Estimate Gas
Estimate gas required for a transaction.
// Estimate for native token transfer
BigInteger gasLimit = await AppKit.EVM.EstimateGasAsync(
"0x123...", // recipient address
1000000000000000000 // 1 ETH in wei
);
// Using parameters object for native transfer
var transferParams = new SendTransactionParams
{
AddressTo = "0x123...",
Value = 1000000000000000000, // 1 ETH in wei
Data = "0x" // optional data
};
BigInteger gasLimit = await AppKit.EVM.EstimateGasAsync(transferParams);
// Estimate for contract interaction
string contractAbi = "[ /* Your contract ABI */ ]";
BigInteger gasLimit = await AppKit.EVM.EstimateGasAsync(
"0x123...", // contract address
contractAbi,
"transfer", // method name
0, // value in wei
"0x456...", // method arguments
1000
);
// Using parameters object for contract interaction
var contractGasParams = new WriteContractParams
{
ContractAddress = "0x123...",
ContractAbi = contractAbi,
MethodName = "transfer",
Value = 0, // optional value in wei
Arguments = new object[] { "0x456...", 1000 }
};
BigInteger gasLimit = await AppKit.EVM.EstimateGasAsync(contractGasParams);
Get Gas Price
Get the current gas price in wei.
BigInteger gasPrice = await AppKit.EVM.GetGasPriceAsync();
RPC Request
Make a direct RPC request to the blockchain node.
// Get the latest block number
BigInteger blockNumber = await AppKit.EVM.RpcRequestAsync<BigInteger>("eth_blockNumber");
// Get transaction by hash
var transaction = await AppKit.EVM.RpcRequestAsync<object>("eth_getTransactionByHash", "0x123...");
// Call a custom method with multiple parameters
var result = await AppKit.EVM.RpcRequestAsync<object>("custom_method", param1, param2);