AppKit Usage Guide for Blockchain Interaction

·

AppKit is a powerful tool for developers looking to seamlessly integrate blockchain functionality into their applications. Whether you're building on Unity or targeting WebGL platforms, AppKit simplifies interactions with EVM-compatible blockchains through preconfigured integrations with Nethereum and Wagmi. This guide walks you through core functionalities such as sending transactions, reading blockchain state, and interacting with smart contracts—ensuring a smooth development experience across platforms.

With AppKit, your app gains the ability to connect to wallet providers, manage user accounts, and execute both read and write operations on the blockchain with minimal setup. Let’s dive into how you can leverage these capabilities effectively.

Sending Ether with AppKit

One of the most common blockchain operations is transferring Ether between addresses. AppKit streamlines this process using the SendTransactionAsync method available via the AppKit.Evm interface.

Here’s how to send 0.001 ETH to a specified address:

const string toAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
BigInteger amount = Web3.Convert.ToWei(0.001);
string result = await AppKit.Evm.SendTransactionAsync(toAddress, amount);

Debug.Log("Transaction hash: " + result);

This transaction uses the standard gas limit of 21,000 units for simple Ether transfers. The gas price is automatically determined by the connected wallet provider, ensuring compatibility with current network conditions. Users will be prompted to confirm the transaction in their wallet before it's broadcasted to the network.

👉 Discover how easy blockchain integration can be with the right tools.

Reading Blockchain State

Reading data from the blockchain is essential for displaying real-time information like balances and token holdings. Unlike write operations, these are cost-free and do not require user confirmation.

Get Ether Balance

To retrieve a user’s ETH balance, first obtain the active account, then query the balance using GetBalanceAsync:

Account account = await AppKit.GetAccountAsync();
BigInteger balance = await AppKit.Evm.GetBalanceAsync(account.Address);

Debug.Log($"Balance: {Web3.Convert.FromWei(balance.Value)} ETH");

This approach ensures accurate, up-to-date balance information directly from the blockchain.

Interacting with Smart Contracts

Smart contract interaction forms the backbone of decentralized applications (dApps). AppKit supports both read and write operations through ReadContractAsync and WriteContractAsync, making it easy to engage with deployed contracts.

Retrieve ERC20 Token Balance

Fetching an ERC20 token balance involves calling the balanceOf function on the token contract. This is a read-only operation that doesn’t alter blockchain state.

const string contractAddress = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984";
const string ownerAddress = "0x3D30B1aB88D487B0F3061F40De76845Bec3F1e94";
const string abi = "..."; // ABI of the ERC20 token contract

var evm = AppKit.Evm;
var tokenBalance = await evm.ReadContractAsync(contractAddress, abi, "balanceOf", new object[] { ownerAddress });
var tokenDecimal = await evm.ReadContractAsync(contractAddress, abi, "decimals");

var finalBalance = (double)tokenBalance / Math.Pow(10, (int)tokenDecimal);
Debug.Log($"Token Balance: {finalBalance}");

The result is normalized using the token’s decimal precision to present a human-readable value.

Sending ERC20 Tokens

Transferring ERC20 tokens requires a state-changing transaction. Users must sign the transaction via their wallet.

const string contractAddress = "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984";
const string recipientAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045";
const string abi = "..."; // ABI of the ERC20 token contract

BigInteger amount = 1;
var arguments = new object[] { recipientAddress, amount };

// Estimate gas required
var gasAmount = await AppKit.Evm.EstimateGasAsync(contractAddress, abi, "transfer", arguments: arguments);

// Execute transfer
var result = await AppKit.Evm.WriteContractAsync(contractAddress, abi, "transfer", gasAmount, arguments);
Debug.Log("Transaction hash: " + result);

Gas estimation helps prevent transaction failures due to insufficient gas, improving user experience.

Deep Integration with Nethereum

For advanced use cases, AppKit provides direct access to Nethereum, a .NET library for Ethereum blockchain interaction. This integration is fully supported on native platforms and offers limited functionality on WebGL.

You can retrieve a preconfigured Web3 instance from AppKit:

var nethereumService = AppKit.Evm as NethereumEvmService;
var web3 = nethereumService.Web3;

This instance is already set up with:

⚠️ Avoid caching the Web3 instance. It may become outdated if the user changes networks or reconnects wallets.

👉 Unlock advanced blockchain features in your app today.

Frequently Asked Questions (FAQ)

Q: Does AppKit support non-EVM blockchains?
A: Currently, AppKit focuses on EVM-compatible chains. Support for additional blockchain ecosystems may be introduced in future updates.

Q: Can I use custom RPC nodes with AppKit?
A: Yes, AppKit allows configuration of custom RPC endpoints during initialization. However, the default setup uses Reown’s optimized Blockchain API for reliability and speed.

Q: Is user wallet connection required for all operations?
A: Read operations (like balance checks) don’t require an active wallet connection. However, any write operation—such as sending tokens or interacting with contracts—requires user authentication and transaction signing.

Q: How does AppKit handle chain switching?
A: When a user switches chains, AppKit automatically updates its internal configuration, including RPC endpoints and contract interfaces. Any cached instances (like Web3) should be re-fetched to ensure consistency.

Q: What happens if a transaction fails?
A: Failed transactions are reported via exceptions. Developers should implement error handling around WriteContractAsync and SendTransactionAsync calls to manage re-submission or user feedback.

Q: Can I integrate AppKit with existing dApp frontends?
A: Absolutely. AppKit is designed for flexibility and can be integrated into Unity-based dApps or hybrid web-mobile applications targeting multiple platforms.

Final Thoughts

AppKit bridges the gap between complex blockchain protocols and intuitive developer workflows. By abstracting low-level details like RPC management and wallet routing, it empowers creators to focus on building engaging, decentralized experiences.

Whether you're sending Ether, querying token balances, or executing smart contract methods, AppKit delivers consistent performance across environments—with special optimizations for WebGL and native platforms alike.

As blockchain adoption grows in gaming, finance, and digital identity spaces, tools like AppKit will play a crucial role in accelerating innovation.

👉 See what’s possible when development meets decentralization.