LogoLogo
Cryptum.ioGitHub
  • 🌐Cryptum
    • What is Cryptum
    • DeFi Market
    • Ecosystem
      • Bitcoin
      • Ethereum
      • Polygon
      • Avalanche C-Chain
      • BNB Chain
      • Cardano
      • Celo
      • Hathor
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
      • Hyperledger Besu
  • 👝Products
    • Dashboard Analytics
    • Tokenization
    • Crypto Checkout
      • Overview
      • Getting started
      • Checkout Dashboard
        • Creating your Store
        • Customer Checkout screens
        • Analytics
        • Managing Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
      • Checkout API
        • Authentication
        • Store
        • Orders
          • Handling Orders
    • Wallets
    • DeFi-as-a-Service
    • On & Off Ramp (soon)
    • E-commerce Plugins
      • Wordpress NFT Plugin
        • How to install NFT Plugin
        • Connect your Credentials to NFT Plugin
      • Wordpress Checkout Plugin
        • How to install Checkout Plugin
        • Connect your Credentials to Checkout Plugin
      • Plugins Guides
        • Creating your Store
        • Manage your Wallets
        • Creating Collections and NFTs
        • Linking Products to NFTs
        • Monitoring Orders
        • Monitoring Store (Analytics)
  • 💻Community Edition
    • Overview
    • Architecture
    • Start for free
    • Getting started
    • Dashboard guide
      • 🔑Creating a Project (API Key)
      • 🛠️Start building!
      • 📊Monitoring your Project
      • 📈Monitoring Requests
    • SDK guides
      • Get test currencies
      • Chainlink
        • 📈Price Feeds
        • ⚙️Automation
        • 🎲VRF
        • 🛤️CCIP
        • 🛤️CCIP
        • Project Examples
          • Lottery
          • Send Message CCIP
      • Wallets
      • Balances
      • Prices
      • Tokens
        • EVM Tokens (ERC-20)
        • Solana Tokens (SPL)
        • Cardano Tokens
        • Stellar Tokens
        • XRP Tokens
        • Hathor Tokens
      • NFTs
        • EVM NFTs (Ethereum, Polygon and others)
        • NFTs on Solana
        • NFTs on Hathor Network
      • Queries
        • Wallet information
        • Get transaction by hash
        • Get block information
        • Get transaction receipt by hash
        • Get fees information
        • Get NFT data
        • Get NFT balance
        • Get UTXOs (Unspent transaction outputs)
      • Uniswap
      • Staking
      • Smart Contracts
        • Deploy custom Smart Contracts
        • Loot Box
    • Features and credits
      • Avalanche C Chain
      • Bitcoin
      • BNB Chain
      • Cardano
      • Celo
      • Ethereum
      • Hathor
      • Polygon
      • Solana
      • Stellar
      • XRP Ledger
      • Stratus
    • API guides
      • API Cryptum
      • API Connector
  • 📃GLOSSARY
    • Blockchain terms
    • Cryptum terms
Powered by GitBook
On this page
  • Creating an ERC-20 token
  • Minting tokens
  • Burning tokens
  • Transferring tokens
  1. Community Edition
  2. SDK guides
  3. Tokens

EVM Tokens (ERC-20)

How to create Tokens on Ethereum, Polygon, Celo, BSC, Avalanche C Chain, Stratus, Hyperledger Besu

PreviousTokensNextSolana Tokens (SPL)

Last updated 1 year ago

Straight to the code!

Instantiate Cryptum SDK first:

const sdk = new CryptumSdk({
  environment: 'testnet',
  apiKey: 'YOUR-API-KEY',
})

Create ERC20 token

sdk.token.create(opts)

The smart contract used in this deployment is already precompiled in Cryptum. For more details, you can see the source code here ./contracts/TokenERC20.sol.

  • opts.wallet (Wallet) (required) - wallet creating the token.

  • opts.name (string) (required) - token name.

  • opts.symbol (string) (required) - token symbol.

  • opts.decimals (number) (required) - token decimal places.

  • opts.amount (string) (required) - token amount to be first minted. (this is in largest unit ether)

  • opts.protocol (string) (required) - .

This function returns the transaction hash from the blockchain. This hash can be used later to retrieve the token address.

const { hash } = await sdk.token.create({
  wallet,
  name: 'Token name',
  symbol: 'TOK',
  decimals: 18,
  amount: '1000000',
  protocol: 'ETHEREUM',
})

Transfer tokens

sdk.token.transfer(opts)

Transfer native and ERC20 tokens.

  • opts.wallet (Wallet) (required) - wallet transferring tokens.

  • opts.token (string) (required) - token name if it's native, like BNB, CELO, ETH etc, or the token address for ERC20 tokens.

  • opts.amount (string) (required) - token amount to be transferred. (this is in largest unit ether)

  • opts.destination (string) (required) - destination address.

  • opts.protocol (string) (required) - .

This function returns the hash of this transferring transaction from the blockchain.

// native token
const { hash } = await sdk.token.transfer({
  wallet,
  protocol: 'POLYGON',
  token: 'MATIC',
  destination: '0x31ec6686ee15...931b5e12cacb920e',
  amount: '17.44',
})
// custom ERC20 token
const { hash } = await sdk.token.transfer({
  wallet,
  protocol: 'AVAXCCHAIN',
  token: '0x1b5e12ca...1b5e12ca',
  destination: '0x31ec6686ee15...07A931b5e12cacb920e',
  amount: '9.129045',
})

Mint tokens

sdk.token.mint(opts)

Mint ERC20 tokens.

*Obs: This method will only work for the tokens created with the method .

  • opts.wallet (Wallet) (required) - wallet minting tokens.

  • opts.token (string) (required) - token address.

  • opts.amount (string) (required) - token amount to be minted. (this is in largest unit ether considering the token decimal places)

  • opts.destination (string) (required) - destination address.

  • opts.protocol (string) (required) - .

This function returns the hash of this minting transaction from the blockchain.

const { hash } = await sdk.token.mint({
  wallet,
  protocol: 'CELO',
  token: '0x1b5e12ca...1b5e12ca',
  destination: '0x31ec6686ee1597...A931b5e12cacb920e',
  amount: '40',
})

Burn tokens

sdk.token.burn(opts)

Burn ERC20 tokens.

*Obs: This method will only work for the tokens created with the method .

  • opts.wallet (Wallet) (required) - wallet burning tokens.

  • opts.token (string) (required) - token address.

  • opts.amount (string) (required) - token amount to be burnt. (this is in largest unit ether considering the token decimal places)

  • opts.protocol (string) (required) - .

This function returns the hash of this burning transaction from the blockchain.

const { hash } = await sdk.token.burn({
  wallet,
  protocol: 'CELO',
  token: '0x1b5e12ca...1b5e12ca',
  amount: '8.23',
})

Approve tokens

sdk.token.approve(opts)

Invoke method "approve" from ERC20-compatible smart contracts.

*Obs: This method will only work for the tokens compatible with ERC-20 standard.

  • opts.wallet (Wallet) (required) - wallet signing transaction that owns the tokens.

  • opts.token (string) (required) - token address.

  • opts.amount (string) (required) - token amount to be approved. (this is in largest unit ether considering the token decimal places)

  • opts.spender (string) (required) - address allowed to withdraw tokens from this wallet.

  • opts.protocol (string) (required) - .

This function returns the hash of this burning transaction from the blockchain.

const { hash } = await sdk.token.approve({
  wallet,
  protocol: 'CELO',
  token: '0x1b5e12ca...1b5e12ca',
  amount: '8.82',
  spender: '0x9377888...3342232'
})

Creating an ERC-20 token

Step 1

As with most actions performed using Cryptum, the first thing you need to do is create an instance of the SDK like this:

const CryptumSdk = require('cryptum-sdk')

const sdk = new CryptumSdk({
  environment: 'testnet',  // 'testnet', 'mainnet'
  apiKey: "YOUR-API-KEY-HERE",
})

Step 2

Now you must have or create a Wallet object using the SDK. This wallet will be used to send transactions to the blockchain in order to create your token, so make sure it has enough funds to perform all the desired interactions.

const wallet = await sdk.wallet.generateWallet({
    protocol: 'ETHEREUM',
    mnemonic: 'lorem ipsum dolor sit amet consectetur adipiscing elit ...',
    derivation: { account: 0, address: 0 }
})

Step 3

const { hash } = await sdk.token.create({
    wallet,
    name: 'Token name',
    symbol: 'TOK',
    decimals: 18,
    amount: '1000000',
    protocol: 'ETHEREUM'
})

The function returns the transaction hash of the smart contract deployment to the blockchain. To use this new token you need its address which you can retrive it from like this:

const { contractAddress } = await sdk.transaction.getTransactionReceiptByHash({
    protocol: 'ETHEREUM',
    hash: '0x000.....'
})

Minting tokens

If you’re the owner of the token’s contract, you can mint extra tokens like this:

const { hash } = await sdk.token.mint({
      wallet,
      token: '0x19......86B',  // token address
      destination: '0x0c3.....A342',  // destination address
      amount: '40',
      protocol: 'ETHEREUM'
})

Burning tokens

Unlike minting, anybody can burn the tokens they own.

const { hash } = await sdk.token.burn({
      wallet,
      token: '0x19......86B',  // token address
      amount: '40',
      protocol: 'ETHEREUM'
})

Transferring tokens

To transfer tokens between accounts, follow this guideline:

const { hash } = await sdk.token.transfer({
      wallet,
      token: '0x19......86B',  // token address
      destination: '0x0c3.....A342',  // destination address
      amount: '40',
      protocol: 'ETHEREUM'
})

Besides ERC20-based tokens, you also can transfer native tokens by passing the native token symbol instead of the token address. Depending on the protocol you're using there are the supported native tokens that you can transfer:

  • "ETH" for protocol ETHEREUM;

  • "CELO", "cUSD", "cEUR" for protocol CELO;

  • "BNB" for protocol BSC;

  • "MATIC" for protocol POLYGON;

  • "AVAX" for protocol AVAXCCHAIN;

  • "CWN" for protocol STRATUS;

const { hash } = await sdk.token.transfer({
      wallet,
      token: 'ETH',  // token address
      destination: '0x0c3.....A342',  // destination address
      amount: '0.037',
      protocol: 'ETHEREUM'
})

Now we must call the sdk.token.create function on the SDK. The smart contract used in this deployment is in the directory, so you must pass as arguments the token name, token symbol, decimals (integer number) and the amount of total supply.

💻
EVMs only
EVMs only
sdk.token.create
EVMs only
sdk.token.create
EVMs only
EVMs only
contracts