Nethereum.StandardTokenEIP20 7.1.0

Prefix Reserved
dotnet add package Nethereum.StandardTokenEIP20 --version 7.1.0
                    
NuGet\Install-Package Nethereum.StandardTokenEIP20 -Version 7.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nethereum.StandardTokenEIP20" Version="7.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nethereum.StandardTokenEIP20" Version="7.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Nethereum.StandardTokenEIP20" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nethereum.StandardTokenEIP20 --version 7.1.0
                    
#r "nuget: Nethereum.StandardTokenEIP20, 7.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nethereum.StandardTokenEIP20@7.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nethereum.StandardTokenEIP20&version=7.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Nethereum.StandardTokenEIP20&version=7.1.0
                    
Install as a Cake Tool

Nethereum.StandardTokenEIP20

StandardTokenService: the original typed service for EIP-20 (ERC-20) token contracts, with a deployable reference token

NuGet

Overview

This package holds one service class, StandardTokenService, a generated-style wrapper around a ContractHandler for an EIP-20 token, together with the function, event and deployment messages it uses (EIP20Deployment carries the bytecode of a reference token, so you can deploy a test token). The package description is "Ethereum Service to interact with EIP20 compliant contracts".

The built-in, current way to work with any ERC-20 token is web3.Eth.ERC20 (Nethereum.Contracts.Standards.ERC20.ERC20Service, also reachable as web3.Eth.StandardTokenERC20), which creates a typed ERC20ContractService for a contract address with web3.Eth.ERC20.GetContractService(address) and adds multicall and batch balance helpers. Prefer it for new code that reads or sends tokens. Reach for Nethereum.StandardTokenEIP20 when you want to deploy the bundled EIP20Deployment token, or when existing code already uses StandardTokenService. The source does not mark the package or StandardTokenService obsolete; only the event classes Events.DTO.Transfer and Events.DTO.Approval carry [Obsolete] ("Please use TransferEventDTO instead" / "Please use ApprovalEventDTO instead").

Installation

dotnet add package Nethereum.StandardTokenEIP20

Depends on Nethereum.Web3.

StandardTokenService

Namespace Nethereum.StandardTokenEIP20.

public class StandardTokenService
{
    public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Web3.Web3 web3,
        EIP20Deployment eIP20Deployment, CancellationTokenSource cancellationTokenSource = null)
    public static Task<string> DeployContractAsync(Web3.Web3 web3, EIP20Deployment eIP20Deployment)
    public static async Task<StandardTokenService> DeployContractAndGetServiceAsync(Web3.Web3 web3,
        EIP20Deployment eIP20Deployment, CancellationTokenSource cancellationTokenSource = null)

    public StandardTokenService(Web3.Web3 web3, string address)
    public ContractHandler ContractHandler { get; }

    public Event<ApprovalEventDTO> GetApprovalEvent()
    public Event<TransferEventDTO> GetTransferEvent()

    public Task<string> NameQueryAsync(NameFunction nameFunction = null, BlockParameter blockParameter = null)
    public Task<string> SymbolQueryAsync(SymbolFunction symbolFunction = null, BlockParameter blockParameter = null)
    public Task<byte> DecimalsQueryAsync(DecimalsFunction decimalsFunction, BlockParameter blockParameter = null)
    public Task<byte> DecimalsQueryAsync(BlockParameter blockParameter = null)
    public Task<BigInteger> TotalSupplyQueryAsync(TotalSupplyFunction totalSupplyFunction, BlockParameter blockParameter = null)
    public Task<BigInteger> TotalSupplyQueryAsync(BlockParameter blockParameter = null)
    public Task<BigInteger> BalanceOfQueryAsync(BalanceOfFunction balanceOfFunction, BlockParameter blockParameter = null)
    public Task<BigInteger> BalanceOfQueryAsync(string owner, BlockParameter blockParameter = null)
    public Task<BigInteger> BalancesQueryAsync(BalancesFunction balancesFunction, BlockParameter blockParameter = null)
    public Task<BigInteger> BalancesQueryAsync(string address, BlockParameter blockParameter = null)
    public Task<BigInteger> AllowanceQueryAsync(AllowanceFunction allowanceFunction, BlockParameter blockParameter = null)
    public Task<BigInteger> AllowanceQueryAsync(string owner, string spender, BlockParameter blockParameter = null)
    public Task<BigInteger> AllowedQueryAsync(AllowedFunction allowedFunction, BlockParameter blockParameter = null)
    public Task<BigInteger> AllowedQueryAsync(string owner, string spender, BlockParameter blockParameter = null)

    public Task<string> TransferRequestAsync(TransferFunction transferFunction)
    public Task<TransactionReceipt> TransferRequestAndWaitForReceiptAsync(TransferFunction transferFunction, CancellationTokenSource cancellationToken = null)
    public Task<string> TransferRequestAsync(string to, BigInteger value)
    public Task<TransactionReceipt> TransferRequestAndWaitForReceiptAsync(string to, BigInteger value, CancellationTokenSource cancellationToken = null)

    public Task<string> TransferFromRequestAsync(TransferFromFunction transferFromFunction)
    public Task<TransactionReceipt> TransferFromRequestAndWaitForReceiptAsync(TransferFromFunction transferFromFunction, CancellationTokenSource cancellationToken = null)
    public Task<string> TransferFromRequestAsync(string from, string to, BigInteger value)
    public Task<TransactionReceipt> TransferFromRequestAndWaitForReceiptAsync(string from, string to, BigInteger value, CancellationTokenSource cancellationToken = null)

    public Task<string> ApproveRequestAsync(ApproveFunction approveFunction)
    public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(ApproveFunction approveFunction, CancellationTokenSource cancellationToken = null)
    public Task<string> ApproveRequestAsync(string spender, BigInteger value)
    public Task<TransactionReceipt> ApproveRequestAndWaitForReceiptAsync(string spender, BigInteger value, CancellationTokenSource cancellationToken = null)
}

NameQueryAsync and SymbolQueryAsync read the result with a StringBytes32Decoder, so tokens that return bytes32 names (such as older DAI) decode as well as string ones. Note that BalancesQueryAsync and AllowedQueryAsync call the reference token's public balances and allowed mappings; use BalanceOfQueryAsync and AllowanceQueryAsync for any standard token.

Deploy a token, transfer, approve and read the event

var tokenService = await StandardTokenService.DeployContractAndGetServiceAsync(web3,
    new EIP20Deployment
    {
        InitialAmount = totalSupply,
        TokenName = "TestToken",
        TokenSymbol = "TST"
    });

var name = await tokenService.NameQueryAsync();
var symbol = await tokenService.SymbolQueryAsync();
var supply = await tokenService.TotalSupplyQueryAsync();
var ownerBalance = await tokenService.BalanceOfQueryAsync(OwnerAddress);

var transferReceipt = await tokenService.TransferRequestAndWaitForReceiptAsync(OtherAddress, 1000);

var transferEvent = tokenService.GetTransferEvent();
var filter = await transferEvent.CreateFilterAsync(new BlockParameter(transferReceipt.BlockNumber));
var logs = await transferEvent.GetAllChangesAsync(filter);

await tokenService.ApproveRequestAndWaitForReceiptAsync(OtherAddress, 500);
var allowance = await tokenService.AllowanceQueryAsync(OwnerAddress, OtherAddress);

The deployer holds the whole InitialAmount; logs holds one TransferEventDTO (From, To, Value). web3 is a Web3.Web3 whose account owns OwnerAddress; in the test it comes from an in-process DevChainNode (node.CreateWeb3(privateKey)), but any Web3 works. Backed by StandardTokenServicesDevChainTests.ShouldDeployATokenTransferApproveAndReadTheTransferEvent (DocSection.SmartContracts, standard-token-eip20) in tests/Nethereum.StandardTokenEIP20.IntegrationTests/StandardTokenServicesDevChainTests.cs.

Messages and events

Namespace Nethereum.StandardTokenEIP20.ContractDefinition.

public partial class EIP20Deployment : EIP20DeploymentBase
{
    public EIP20Deployment()
    public EIP20Deployment(string byteCode)
}

public class EIP20DeploymentBase : ContractDeploymentMessage
{
    public static string BYTECODE
    public virtual BigInteger InitialAmount { get; set; }
    public virtual string TokenName { get; set; }
    public virtual byte DecimalUnits { get; set; }
    public virtual string TokenSymbol { get; set; }
}

(BYTECODE is empty when the package is built with BYTECODELITE.)

Function messages (each a FunctionMessage): NameFunction, SymbolFunction, DecimalsFunction, TotalSupplyFunction, BalanceOfFunction (Owner), BalancesFunction (Address), AllowanceFunction (Owner, Spender), AllowedFunction (Owner, Spender), TransferFunction (To, Value), TransferFromFunction (From, To, Value) and ApproveFunction (Spender, Value). Output DTOs: AllowedOutputDTO, BalanceOfOutputDTO, SymbolOutputDTO, AllowanceOutputDTO and others in the same file.

Event DTOs:

[Event("Transfer")]
public class TransferEventDTOBase : IEventDTO
{
    public virtual string From { get; set; }
    public virtual string To { get; set; }
    public virtual BigInteger Value { get; set; }
}

[Event("Approval")]
public class ApprovalEventDTOBase : IEventDTO
{
    public virtual string Owner { get; set; }
    public virtual string Spender { get; set; }
    public virtual BigInteger Value { get; set; }
}

TransferEventDTO and ApprovalEventDTO are the partial classes deriving from these. The older Nethereum.StandardTokenEIP20.Events.DTO.Transfer and Approval classes are [Obsolete].

Tests

tests/Nethereum.StandardTokenEIP20.IntegrationTests/Erc20TokenTester.cs runs the same operations against a local Geth node and Infura mainnet, so it needs those endpoints; it is not used for the example above.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Nethereum.StandardTokenEIP20:

Package Downloads
Nethereum

Package Description

Sfw.Utility.Ethereum

Package Description

DeepMeta.DeepFrozen.ETH

Package Description

TatumCS

TatumCS is a dotnet wrapper for the Tatum Api. It includes support all endpoints

Wonka.Eth

Relying heavily on the Nethereum project, this library contains classes that interact with the Ethereum foundation and that extend the Wonka engine, particulary the base class WonkaBizRulesEngine in the Wonka.BizRulesEngine library. With the funtionality provided here, Wonka becomes a business rules engine for both the .NET platform and the Ethereum platform, one that is inherently metadata-driven and serves as a reference implementation for EIP-2746. Once the rules are written into a markup language and are parsed/deserialized by the .NET form of the engine, these rules can then be serialized onto the blockchain using Nethereum, and stored within a smart contract (i.e., the Ethereum version of the engine) built using the Solidity language. The Ethereum version of this engine can also be deployed as a contract by this library. After providing a number of rules and populating a record, a user can submit the populated record for validation by the rules engine, whether it exists in .NET or the blockchain.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.1.0 54 11/10/2026
7.0.0 453 10/2/2026
6.1.0 10,103 3/25/2026
6.0.4 316 3/18/2026
6.0.3 172 3/18/2026
6.0.1 176 3/17/2026
6.0.0 203 3/16/2026
5.8.0 2,985 1/6/2026
5.0.0 25,502 5/28/2025
4.29.0 16,658 2/10/2025
4.28.0 5,389 1/7/2025
4.27.1 743 12/24/2024
4.27.0 325 12/24/2024
4.26.0 3,068 10/1/2024
4.25.0 578 9/19/2024
4.21.4 1,738 8/9/2024
4.21.3 434 7/22/2024
4.21.2 2,340 6/26/2024
4.21.1 609 6/26/2024
4.21.0 725 6/18/2024
Loading failed