Skip to main content

Native ERC-20

peaq inherits the ERC-20 Native Token precompile to interact with the peaq token as is it were a native ERC-20. This prevents the need to have wrapped representations of the same token and allows for easy interaction with the token without the need to deploy another smart contract. This guide will show you how to interact with peaq's testnet token, agung, through this precompile using Remix. If you are new to using Remix please see the guide for proper setup.

NOTE

Compatible Networks: agung & peaq

1. Setup Remix IDE

Get the proper setup in the Remix IDE website. Please visit the link:

Create a new blank workspace for ERC-20 precompile.

2. Create IERC-20 File

After creating a blank project you will need to create a new file. Please create a new filed named IERC-20.sol. The 'I' char is a convention that signifies the standard interface for the ERC-20 tokens. The precompile standard for ERC-20 tokens was created by Moonbeam is directly accessible in our peaq network node documentation here. Please copy the entire file and paste it into your newly created IERC-20.sol file.

3. Compile the Contract

Similarly to the other tutorials using Remix on our documentation pages we will need to compile this contract to obtain the abi locally. After pasting the copied code you are free to compile.

4. Get Contract

Next, we will need to obtain an instance of the deployed ERC-20 contract on our network. To do so go to the Deploy & Run transactions sidebar, select Injected Provider - MetaMask, pick the account with funds, and select the IERC-20.sol contract as shown in the screenshot below.

  • Set 0x0000000000000000000000000000000000000809 found on top of the file in the address and click At Address. Doing so will allow you to interact with the agung ERC-20 contract. Doing so will create a new deployed contract instance on the bottom of the sidebar that you are able to interact with. evm-erc20-1

5. Interact with the Functions

The contract that you are able to interact with will show up on the bottom the the sidebar. Here lie all the functions that are present in the interface. For detailed information about the functions it provides please see the EIP-20 Token Standard. evm-erc20-2