Token module: Endpoint reference

token_getBalances

Returns the balances of all tokens associated with a specific account.

  • Specification

  • Node CLI

  • cURL

Table 1. Parameters
Name Type Description Sample

address

string

Account address.

kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb

klayr-core endpoint:invoke token_getBalances '{"address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}' --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getBalances",
    "params": {"address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}
}'
Response
Example output
{
  "balances": [
    {
      "tokenID": "0200000000000000",
      "availableBalance": "1000000000",
      "lockedBalances": []
    }
  ]
}

token_getBalance

Returns the balance of a specific token associated with a specific account.

  • Specification

  • Node CLI

  • cURL

Table 2. Parameters
Name Type Description Sample

tokenID

string

TokenID of the token to query the balance for.

0200000000000000

address

string

Account address.

kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb

klayr-core endpoint:invoke token_getBalance '{"tokenID":"0200000000000000","address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}' --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getBalance",
    "params": {"tokenID":"0200000000000000","address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}
}'
Response
Example output
{
  "availableBalance": "1000000000",
  "lockedBalances": []
}

token_getTotalSupply

Returns the total supply that exists of a specific token.

  • Specification

  • Node CLI

  • cURL

No Parameters.

klayr-core endpoint:invoke token_getTotalSupply --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getTotalSupply",
    "params": {}
}'
Response
Example output
{
  "totalSupply": [
    {
      "tokenID": "0200000000000000",
      "totalSupply": "11121172542991566"
    }
  ]
}

token_getSupportedTokens

Returns a list of token IDs that are supported in the network.

  • Specification

  • Node CLI

  • cURL

No Parameters.

klayr-core endpoint:invoke token_getSupportedTokens --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getSupportedTokens",
    "params": {}
}'
Response
Example output
{
  "supportedTokens": [
    "0200000000000000",
    "0200000000000000"
  ]
}

token_isSupported

Checks if a specific token is supported by the network.

  • Specification

  • Node CLI

  • cURL

Table 3. Parameters
Name Type Description Sample

tokenID

string

TokenID of the token to query the balance for.

0200000000000000

klayr-core endpoint:invoke token_isSupported '{"tokenID":"0200000000000000"}' --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_isSupported",
    "params": {"tokenID":"0200000000000000"}
}'
Response
Example output
{
  "supported": true
}

token_getEscrowedAmounts

Returns all balances of existing sidechain escrow accounts.

  • Specification

  • Node CLI

  • cURL

No Parameters.

klayr-core endpoint:invoke token_getEscrowedAmounts --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getEscrowedAmounts",
    "params": {}
}'
Response
Example output
{
  "escrowedAmounts": [
    {
      "escrowChainID": "02000007",
      "amount": "0",
      "tokenID": "0200000000000000"
    },
    {
      "escrowChainID": "02000070",
      "amount": "0",
      "tokenID": "0200000000000000"
    },
    {
      "escrowChainID": "02001337",
      "amount": "0",
      "tokenID": "0200000000000000"
    },
    {
      "escrowChainID": "02100000",
      "amount": "0",
      "tokenID": "0200000000000000"
    },
    {
      "escrowChainID": "02100001",
      "amount": "0",
      "tokenID": "0200000000000000"
    }
  ]
}

token_getInitializationFees

Returns the fees for initializing new user and escrow accounts.

  • Specification

  • Node CLI

  • cURL

No Parameters.

klayr-core endpoint:invoke token_getInitializationFees --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_getInitializationFees",
    "params": {}
}'
Response
Example output
{
  "userAccount": "5000000",
  "escrowAccount": "5000000"
}

token_hasUserAccount

Checks if an account exists for the provided address and token in the network.

  • Specification

  • Node CLI

  • cURL

Table 4. Parameters
Name Type Description Sample

tokenID

string

Token ID.

0200000000000000

address

string

Account address.

kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb

klayr-core endpoint:invoke token_hasUserAccount '{"tokenID":"0200000000000000","address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}' --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_hasUserAccount",
    "params": {"tokenID":"0200000000000000","address":"kly55e8u4heymzmxgcrg4dc5xpgd5ckkyv53oxftb"}
}'
Response
Example output
{
  "exists": true
}

token_hasEscrowAccount

Checks if an escrow account exists for the provided chain ID and token in the network.

  • Specification

  • Node CLI

  • cURL

Table 5. Parameters
Name Type Description Sample

tokenID

string

Token ID.

0200000000000000

escrowChainID

string

Escrow chain ID.

02001337

klayr-core endpoint:invoke token_hasEscrowAccount '{"tokenID":"0200000000000000","escrowChainID":"02001337"}' --pretty
curl --location --request POST 'http://localhost:7887/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "id": "1",
    "method": "token_hasEscrowAccount",
    "params": {"tokenID":"0200000000000000","escrowChainID":"02001337"}
}'
Response
Example output
{
  "exists": true
}