erc20

Query and transfer ERC-20 tokens using Nethereum typed services in C#.

2.3k|744|Updated Nov 23, 2015
One-click install
npx skills add https://github.com/Nethereum/Nethereum --skill erc20
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: erc20
Source: https://github.com/Nethereum/Nethereum/tree/main/plugins/nethereum-skills/skills/erc20
Command: npx skills add https://github.com/Nethereum/Nethereum --skill erc20

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires Nethereum.Web3.

What problem does it solve?

Interacting with ERC-20 tokens in .NET normally requires ABI definitions and code generation. This Skill shows how to use Nethereum's built-in typed ERC-20 service to query balances, transfer tokens, and manage approvals directly from C# with no ABI or generated code.

Core Features & Use Cases

  • Token Metadata & Balances: Read name, symbol, decimals, total supply, and account balances with simple async query calls, converting values with Web3.Convert.FromWei.
  • Transfers & Approvals: Send tokens and manage the approve/transferFrom allowance pattern with automatic gas estimation, nonce handling, and EIP-1559 fees.
  • Event & Historical Queries: Listen for Transfer events using the built-in TransferEventDTO and query balances at specific historical blocks.
  • Use Case: Build a wallet feature that displays a user's USDC balance (6 decimals) and lets them transfer tokens to another address with a few lines of C#.

Quick Start

Use the erc20 skill to check the balance of a token contract for my address and transfer 100 tokens to a recipient using Nethereum in C#.

Frequently Asked Questions about erc20

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check an ERC-20 token balance in C#?

Use Nethereum's built-in typed service: call web3.Eth.ERC20.GetContractService(contractAddress), then await BalanceOfQueryAsync(address). The result is in the token's smallest unit, so convert it with Web3.Convert.FromWei(balance, decimals).

How to transfer ERC-20 tokens with Nethereum?

Get the typed ERC-20 service for the token contract, then call TransferRequestAndWaitForReceiptAsync with the recipient address and amount in the smallest unit via Web3.Convert.ToWei. Gas estimation, nonce, and EIP-1559 fees are handled automatically.

Does Nethereum require an ABI to interact with ERC-20 tokens?

No. Nethereum ships a built-in typed ERC-20 service, so no ABI or code generation is needed. Just provide the token contract address to GetContractService and call methods like NameQueryAsync or TransferRequestAndWaitForReceiptAsync directly.

How do I handle token decimals when displaying balances?

ERC-20 balances are stored as integers in the smallest unit, so always read DecimalsQueryAsync first and convert with Web3.Convert.FromWei(value, decimals). Most tokens use 18 decimals, but stablecoins like USDC use 6.

Can I query ERC-20 balances at a past block?

Yes, all query methods accept an optional BlockParameter to read state at a specific block, such as BalanceOfQueryAsync(address, new BlockParameter(15000000)). The connected node must retain archive state for the requested block.

What are the risks of ERC-20 approve and allowance?

Approving a spender gives them permission to transfer up to that amount from your account at any time via transferFrom. Check current limits with AllowanceQueryAsync and avoid approving amounts larger than necessary.