Getting started

Covering the basics from authentication to minting your first ERC20 token.

What we cover in this guide

In this guide, we will explain how to authenticate to our API service, as well as mint your first ERC20 token. We will walk you through several endpoints to help you get started. We will cover the following topics:

  1. Authentication
  2. Creating a Token Contract
  3. Checking Token Contract Status
  4. Minting ERC20 Token
  5. Checking Token Mint Status

Prerequisites

  1. You need a Venly business account, if you don't have one, click here to register in our Developer Portal, or follow our step-by-step guide, Getting Started with Venly.
  2. You need your Client ID and Client Secret which can be obtained from the Portal as shown below.
Access Credentials - Developer Portal

Access Credentials - Developer Portal

📘

All the API calls for this guide run on a sandbox environment. You can test and experiment with API calls without causing any harm to the actual blockchain or data.

There are several ways to run API calls, but for this guide, you can use the API-Reference or Postman to execute the different endpoints.

1. Authenticating

You will need your access credentials (Client ID and Client Secret) to obtain a bearer token and authorize all API calls. These credentials are necessary for authentication purposes.

📘

  • Learn how to retrieve a bearer token and authenticate API calls.
  • Please note that the base path for all Token API endpoints is https://token-api-sandbox.venly.io

2. Create token contract

Let's start by defining your first contract. We will create a contract on the MATIC testnet chain.

Request Endpoint: reference

 POST /api/v3/erc20/contracts/deployments

Request Body:

ParameterDescriptionTypeRequired
chainThis is the blockchain on which you want to create the token contract onString
nameThe name of your token contractString
symbolThe symbol for your token contractString
maxSupplyThe maximum amount of tokens allowed to be mintedInteger
burnableIndication whether the tokens will be burnable or not. Burning tokens is the act of sending tokens to a wallet that cannot be accessedBoolean
ownerThe wallet address that will be the owner of this token contract. The owner will have admin rights on the token contractString
{
    "chain": "MATIC",
    "name": "Venly Test Token",
    "symbol": "VTT",
    "maxSupply": "150",
    "burnable": "true",
    "owner": "0x7312750DF4d2057b758a61C7017729c6Ec9bB3E9"
}

Response Body:

📘

  • Save the result.id from the response body. This is the deployment ID and it is used to check the status of the contract creation request.
  • The transactionHash that is returned is the transction that created the contract on-chain.
  • The status attribute indicates if the transaction has been mined yet.
{
    "success": true,
    "result": {
        "id": "22fa9617-4630-49c1-8cd2-a0145980cd21",
        "chain": "MATIC",
        "name": "Venly Test Token",
        "symbol": "VTT",
        "maxSupply": 150,
        "burnable": true,
        "owner": "0x7312750DF4d2057b758a61C7017729c6Ec9bB3E9",
        "transactionHash": "0xdaae9385afe8a9e91d2f771e1bcb3597eb563fe0ab48cd75d381ac4798ad1359",
        "status": "PENDING"
    }
}

3. Check the token contract deployment status

Next, we will check the deployment status of the token contract using the deployment ID.

Request Endpoint: reference

GET /api/v3/erc20/contracts/deployments/{deploymentId}

Path Variable

{deploymentId}: This can be found in the response of the create token contract endpoint as the result.id parameter.

Example Request

GET /api/v3/erc20/contracts/deployments/22fa9617-4630-49c1-8cd2-a0145980cd21

Response Body

📘

In the response body look for the result.status parameter. It can have three possible values:

  • SUCCEEDED
  • PENDING
  • FAILED
{
    "success": true,
    "result": {
        "id": "22fa9617-4630-49c1-8cd2-a0145980cd21",
        "chain": "MATIC",
        "address": "0x44b1dc2b16e315e846e9f00c11282d19265be983",
        "name": "Venly Test Token",
        "symbol": "VTT",
        "maxSupply": 150,
        "burnable": true,
        "owner": "0x7312750DF4d2057b758a61C7017729c6Ec9bB3E9",
        "transactionHash": "0xdaae9385afe8a9e91d2f771e1bcb3597eb563fe0ab48cd75d381ac4798ad1359",
        "status": "SUCCEEDED"
    }
}

4. Mint ERC20 tokens

Now we have successfully deployed the token contract, we can start to mint ERC20 tokens. Use this endpoint to mint ERC20 tokens by supplying the token contract address and destination wallet address.

Request Endpoint: reference

POST /api/v3/erc20/tokens/mints

Request Body Parameters

ParameterParam TypeDescriptionTypeRequired
chainBodyThe blockchain of the token contractString
contractAddressBodyThe token contract addressString
destinationsBodyThe array includes all the wallet addresses and the number of ERC20 tokens to mint per wallet addressArray of objects
destinations.addressBodyThe wallet address to mint and send the ERC20 tokens toString
destinations.amountBodyThe number of ERC20 tokens you want to mint and sendNumber

Example Request

In this example, we will mint and send ERC20 tokens to two wallet addresses. The first wallet will get five ERC20 tokens and the second wallet will get twenty-five tokens. You can add multiple wallet addresses.

POST /api/v3/erc20/tokens/mints
{
    "chain": "MATIC",
    "contractAddress": "0x44b1dc2b16e315e846e9f00c11282d19265be983",
    "destinations": [
        {
            "address": "0xb811Fac088E8E80F56258a5f29D47d0FF1a37BD5",
            "amount": "5"
        },
        {
            "address": "0xf2b1cEB69E765469a80E8d4c8635B05269889fa7",
            "amount": "25"
        }
    ]
}

Response Body

📘

{
    "success": true,
    "result": {
        "mints": [
            {
                "id": "273e6ecb-fb1b-44f0-a9ff-a19bbf92099a",
                "createdOn": "2024-09-23T09:34:21.973064048",
                "status": "PENDING",
                "destination": {
                    "address": "0xf2b1cEB69E765469a80E8d4c8635B05269889fa7",
                    "amount": 25
                }
            },
            {
                "id": "8a4a03ac-e1e8-4468-bdce-1e57e809d89f",
                "createdOn": "2024-09-23T09:34:21.977695915",
                "status": "PENDING",
                "destination": {
                    "address": "0xb811Fac088E8E80F56258a5f29D47d0FF1a37BD5",
                    "amount": 5
                }
            }
        ],
        "contract": {
            "address": "0x44b1dc2b16e315e846e9f00c11282d19265be983",
            "name": "Venly Test Token",
            "symbol": "VTT",
            "maxSupply": 150,
            "burnable": true,
            "owner": "0x7312750DF4d2057b758a61C7017729c6Ec9bB3E9",
            "type": "ERC_20"
        }
    }
}

5. Check the token mint status

Finally, we will check the token mint request using the mint ID.

Request Endpoint: reference

GET /api/v3/erc20/tokens/mints/{mintId}

Example Request

GET /api/v3/erc20/tokens/mints/273e6ecb-fb1b-44f0-a9ff-a19bbf92099a

Response Body

📘

In the response body look for the result.status parameter. It can have three possible values:

  • SUCCEEDED
  • PENDING
  • FAILED
{
    "success": true,
    "result": {
        "id": "273e6ecb-fb1b-44f0-a9ff-a19bbf92099a",
        "createdOn": "2024-09-23T09:34:21.973064",
        "status": "SUCCEEDED",
        "transactionHash": "0x2196af03642bf02a6ba6f416098ee50d03fba9343edb5938eaa7969e13bef2c2",
        "destination": {
            "address": "0xf2b1cEB69E765469a80E8d4c8635B05269889fa7",
            "amount": 25
        },
        "contract": {
            "address": "0x44b1dc2b16e315e846e9f00c11282d19265be983",
            "name": "Venly Test Token",
            "symbol": "VTT",
            "maxSupply": 150,
            "burnable": true,
            "owner": "0x7312750DF4d2057b758a61C7017729c6Ec9bB3E9",
            "type": "ERC_20"
        }
    }
}

👍

The response shows "status": "SUCCEEDED" , indicating the ERC20 token mint was successful on-chain.