Token Transfer
Karura supports different types of tokens than Kusama, and allows various ways to transfer tokens. This guide will walk through tokens available on Karura, tools can be used for transfers, how to send transfer transactions, monitor and track these transactions.

Token Types

  • Native Network Token
    • KAR
  • Native Protocol Tokens
    • LKSM: tokenized staked KSM from the Liquid Staking protocol
    • kUSD: multi-collateralized stablecoin
  • Foreign Tokens
    • KSM: crossed to Karura from Kusama Relay Chain
    • Tokens originated from other parachains
    • Tokens crossed from other blockchains such as ETH, renBTC or Compound CASH
  • ERC20 Tokens
    • Token issued by ERC20 contracts deployed in Karura EVM

Tools

Token balances

Query chain state to get token balances.

Native token (KAR) balances

Query system module to get native token (KAR) balances data.

system.account

  • Returns the AccountInfo of given account. For different types of balances, check the fields in AccountInfo.data
    • free: the free balance.
    • reserve: the reserved balance.

Other tokens

For non-native tokens, like KSM, LKSM, kUSD, query tokens module to get balances info.

tokens.accounts

  • Returns the OrmlAccountData of given account and currency ID. For different types of balances, check the fields:
    • free: the free balance.
    • reserved: the reserved balance.

tokens.lock

  • Returns the BalanceLock of given account and currency ID. BalanceLock has two fields:
    • id: the lock identifier.
    • amount. the locked amount.
  • Note locks could be overlapped, and the same amount of tokens could be under locked by multiple locks.

Send Tokens

Transactions

currencies.transfer

currencies.transferNativeCurrency

balances.transfer

Receive Tokens

There are multiple ways to detect incoming balance transfers:
  • Monitor events
  • Subscribe storage changes
  • Monitor transactions

Monitor Events

Monitoring events is a recommended way to track incoming balance transfers. It can handle ALL types of transfer transactions including the one that is not initiated by a transaction directly (e.g. delayed proxy).

balances.transfer

currencies.transfer

currencies.deposit

xtokens.transferred

xtokens.transferredmultiasset

Storage changes RPC

    • Subscribe to a list of account balances. However, it does not guarantee subscription delivery due to connection errors or blockchain reorg.

Monitor Transactions

It is possible to fetch transactions in every block, check for transfer transactions, and check if the transfer transaction is successful. However, this may likely yield false-negative results i.e. deposit received but failed to recognize, due to the various ways for transfer.
Refer to Send Tokens section for direct transfer transactions. In additional, to sending transfer transactions individually, there are common utility methods to batch send transfer transactions:

utility.batch

  • This can be used to send batch transaction
  • NOTE: batched transactions will always emit success events.
    • utility.BatchCompleted event indicates that all transactions are successful
    • utility.BatchInterrupted event indicates which transaction failed. Transactions before the failed transaction are executed successfully and will not be reverted.

utility.batchAll

Last modified 3mo ago