Burn ERC20 Token

This guide describes how to burn ERC20 tokens from your wallet.

Burning ERC20 Tokens

Burning an ERC-20 token means permanently removing a certain number of tokens by sending them to an address from which they can never be retrieved, typically an address with no private key (commonly called a "burn address").

The token holder or a smart contract usually does the burning process. The token contract has to be defined as burnable when created to allow burning.

This guide describes how to burn ERC20 tokens that you hold in your wallet.

🚧

Burning tokens is irreversible!

1. List the ERC20 tokens for a wallet

Call the following endpoint to list all ERC20 tokens held in the wallet:

Request Endpoint: reference

 GET /api/wallets/{walletId}/balance/tokens

Path Variables:

walletId: This is the ID of a wallet that holds ERC20 tokens.

Response Body:

📘

From here we choose the ERC20 token that will be burned.

  • result.rawBalance: This is the raw balance of tokens
  • result.tokenAddress: This is the contract address of the NFT
{
    "success": true,
    "result": [
        {
            "tokenAddress": "0xc31c822919b9178fba186b2e7776d10c7c07c717",
            "rawBalance": "20000000000000000000",
            "balance": 20,
            "decimals": 18,
            "symbol": "IFT",
            "type": "ERC20",
            "transferable": true,
            "name": "Infinity Token",
            "possibleSpam": false
        }
    ]
}

👍

Now you should have the following:

  1. Raw balance of tokens you want to burn, for this example we will burn 10 tokens
  2. 1 token equals 1*10^18
  3. Token contract address of the ERC20 token
  4. Wallet ID that holds the ERC20 tokens

2. Burn

Now we need to prepare the execute function to call the burn function as follows:

Request Endpoint: reference

 GET /api/transactions/execute
ParameterParam TypeValueDescription
Signing-MethodHeaderid:valueid: This is the ID of the signing method
value: This is the value of the signing method

Request Body:

ParameterDescriptionData TypeMandatory?
transactionRequest.typeThis will be CONTRACT_EXECUTIONString
transactionRequest.walletIdThe ID of the wallet holding the ERC20 tokensString
transactionRequest.toThe token contract address of the ERC20 tokensString
transactionRequest.secretTypeThe blockchain of the ERC20 tokens (in this case, its MATIC)String
transactionRequest.functionNameThis will be burnString
transactionRequest.inputsAn array of inputs for the burn function (see example below)Array of objects
{
    "transactionRequest": {
        "type": "CONTRACT_EXECUTION",
        "walletId": "78afb2ee-4c5e-4723-9c96-fa7cdead949a", 
        "to": "0xc31c822919b9178fba186b2e7776d10c7c07c717",
        "secretType": "MATIC",
        "functionName": "burn",
        "inputs": [
            {
                "type": "uint256", // keep as is
                "value": "10000000000000000000" // the raw balance of tokens to burn (1 token equals 1*10^18) (in this example we are burning 10 tokens)
            }
        ]
    }
}

Response Body:

{
    "success": true,
    "result": {
        "id": "bcf10d05-d47a-4cee-a844-7f0f4b3a912e",
        "transactionHash": "0xe604ff90052691f1210dbe273f681c3e3cc4d7de62d6fab1706a258584e0d319"
    }
}

Once we have called the burn function using the execute endpoint, we can corroborate if it was burned by listing the ERC20 tokens owned by the wallet as shown above.

3. List the ERC20 tokens for a wallet

Request Endpoint: reference

 GET /api/wallets/{walletId}/balance/tokens

Path Variables:

walletId: This is the ID of a wallet that holds ERC20 tokens.

Response Body:

👍

We can see that the wallet now has only 10 tokens, indicating the burn was successful!

{
    "success": true,
    "result": [
        {
            "tokenAddress": "0xc31c822919b9178fba186b2e7776d10c7c07c717",
            "rawBalance": "10000000000000000000",
            "balance": 10,
            "decimals": 18,
            "symbol": "IFT",
            "type": "ERC20",
            "transferable": true,
            "name": "Infinity Token",
            "possibleSpam": false
        }
    ]
}