Create & send FT

Send ERC20 coins to a user and check balance

๐Ÿ”ญ Guide overview

In this guide you will send ERC20 tokens. After sending, will check user wallet balance.

๐Ÿ“˜

ERC20: Crypto Coins ๐Ÿช™ , also known as fungible tokens.

The ERC-20 introduces a standard for Fungible Tokens, in other words, they have a property that makes each token be exactly the same (in type and value) as another token. For example, 1 ERC-20 token is and will always be equal to all the other tokens. Some popular examples of ERC-20 tokens are WETH, MATIC.

Learn more about the type of tokens: Ethereum.org docs on ERC20 tokens โ†—๏ธ

๐Ÿท๏ธ Use-case examples with the Croak ERC-20 APIs

  • Reward users with coins
  • Airdrop tokens to non-users for inviting them to use your application
  • Reward community members for their contributions
  • Send a user coins/fungible tokens in exchange of fiat payments. These coins can be used for ingame actions
  • Assign reputation points for users in an online platform
  • Assign financial assets to shareholders like a share in a company/dao

๐Ÿงฑ Implementation steps

  1. We have already deloyed anERC20 contract for you that gives you rights to mint new coins and send to user's wallets.
  2. Fetch the token id: Get the testERC20tokenDataIds of your client. If you don't already have it saved go to Get Company API Reference โ†—๏ธ and create a new client to start using. Here we will assume - 62a369c43a45893dcf7bae66 is the tokenDataId.
  3. Send the tokens: Use the following API to mint new ERC20 tokens to a wallet. eg. here we will mint 100000 of this into my walletId - 627cb7ea2cd263018f2adfb7. See API Reference for code snippets in more languages โ†—๏ธ
> curl --request POST \
     --url https://be.namasteapis.com/blockchain/v1/airdrop/test-fungible-token-data \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header 'x-api-key: TheCompanyAPIkey' \
     --data '
{
     "destinations": [
          "627cb7ea2cd263018f2adfb7"
     ],
     "amounts": [
          100000
     ],
     "tokenDataId": "62a369c43a45893dcf7bae66"
}
'

{
  "data": [
    {
      "chainId": 80001,
      "hash": "0x31898f611d9d31223258b7d8f68698f67448f686737dcaf69af050fda6ba3d2f",
      "transactionId": "d0e33533-0ff2-4b8e-b670-640553ce4039",
      "value": "0x0",
      "gasPrice": 30000000000,
      "gasLimit": 2500000,
      "to": "0x5d38889BFcB2610ab7387c5AC3aC7b56265fc93A",
      "from": "0x923dacd378daae95d4ba88aae08d598609acf0b6",
      "data": "0x40c10f190000000000000000000000008e8132a63eed858cb8abb3b7d0bd3c4df9e1b6bd00000000000000000000000000000000000000000000000000000000000186a0",
      "nonce": 134,
      "status": "sent",
      "speed": "fast",
      "validUntil": "2022-06-11T02:33:07.261Z",
      "createdAt": "2022-06-10T18:33:08.182Z",
      "sentAt": "2022-06-10T18:33:08.182Z",
      "pricedAt": "2022-06-10T18:33:08.182Z"
    }
  ],
  "success": true,
  "message": "Token minting started"
}

You can try it yourself ๐Ÿ˜Ž here!

  1. Check balance: Get your fungible token balance using the following API. See API reference for code snippets in more languages โ†—๏ธ
> curl --request GET \
     --url 'https://be.namasteapis.com/blockchain/v1/wallet-balance/test-erc20?walletId=627cb7ea2cd263018f2adfb7' \
     --header 'Accept: application/json' \
     --header 'x-api-key: TheCompanyAPIkey'
     
     
{
  "data": [
    {
      "chain": "mumbai",
      "balance": "0.0000000000000000001",
      "decimals": 18,
      "symbol": "",
      "rawBalance": "100000"
    }
  ],
  "success": true,
  "message": "Wallet fungible token balance!"
}

You can try it yourself ๐Ÿ˜Ž here!

  1. That's it you're done ๐Ÿ

๐Ÿ“Œ Further queries

For any queries or guidance, join https://croak.discord.com or write to [email protected]


Did this page help you?