Get Token Info#
get_token_infoAPI-v2 get_token_info #
The get_token_info method returns the ticker and decimals values (required for activation) given a platform and contract as input. The platform parent coin (e.g., ETH, AVAX, MATIC, etc.) must be activated before using this method. After requesting the token info, you will be able to activate the custom token.
Note
Custom tokens will be wallet_only—i.e., you can send and receive tokens, but will not be able to do atomic swaps. To apply for a formal listing of the custom token, please review the requirements in our “coins” GitHub repository, and get in touch with our team on the KomodoPlatform Discord .
Request Parameters#
Parameter Type Required Description protocol object
✓
A standard TokenProtocol object.
Response Parameters#
Parameter Type Required Description type string
✓
Token type—e.g., PLG20 for tokens on the Polygon network. info.symbol string
✓
The ticker of the token linked to the contract address and network requested. info.decimals integer
✓
Defines the number of digits after the decimal point that should be used to display the orderbook amounts, balance, and the value of inputs to be used in the case of order creation or a withdraw transaction. The default value used for a UTXO type coin (Bitcoin protocol) is 8, and the default value used for an ERC20 token is 18. It is very important for this value to be set correctly. For example, if this value was set as 9 for BTC, a command to withdraw 1 BTC tries to withdraw 10^9 satoshis of Bitcoin, i.e., 10 BTC.
📌 Examples#
JSON Bash Python JavaScript PHP Go Ruby
Copy
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "get_token_info" ,
"params" : {
"protocol" : {
"type" : "ERC20" ,
"protocol_data" : {
"platform" : "AVAX" ,
"contract_address" : "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
}
Copy
curl --url "http://127.0.0.1:7783" --data '{
"userpass": "RPC_UserP@SSW0RD",
"mmrpc": "2.0",
"method": "get_token_info",
"params": {
"protocol": {
"type": "ERC20",
"protocol_data": {
"platform": "AVAX",
"contract_address": "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
}'
Copy
import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "get_token_info" ,
"params" : {
"protocol" : {
"type" : "ERC20" ,
"protocol_data" : {
"platform" : "AVAX" ,
"contract_address" : "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
}
response = requests.post(url, json = payload)
print (json.dumps(response.json(), indent = 2 ))
Copy
const payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "get_token_info" ,
"params" : {
"protocol" : {
"type" : "ERC20" ,
"protocol_data" : {
"platform" : "AVAX" ,
"contract_address" : "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
};
const response = await fetch ( "http://127.0.0.1:7783" , {
method: "POST" ,
body: JSON . stringify (payload),
});
console. log ( await response. json ());
Copy
<? php
$payload = <<< ' JSON '
{
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "get_token_info" ,
"params" : {
"protocol" : {
"type" : "ERC20" ,
"protocol_data" : {
"platform" : "AVAX" ,
"contract_address" : "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
}
JSON ;
$ch = curl_init ( "http://127.0.0.1:7783" );
curl_setopt ($ch, CURLOPT_POST , true );
curl_setopt ($ch, CURLOPT_POSTFIELDS , $payload);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER , true );
curl_setopt ($ch, CURLOPT_HTTPHEADER , [ 'Content-Type: application/json' ]);
$response = curl_exec ($ch);
curl_close ($ch);
echo $response;
Copy
package main
import (
" bytes "
" fmt "
" io "
" net/http "
)
func main () {
payload := [] byte ( `{"userpass":"RPC_UserP@SSW0RD","mmrpc":"2.0","method":"get_token_info","params":{"protocol":{"type":"ERC20","protocol_data":{"platform":"AVAX","contract_address":"0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"}}}}` )
resp, err := http. Post ( "http://127.0.0.1:7783" , "application/json" , bytes. NewBuffer (payload))
if err != nil {
panic (err)
}
defer resp.Body. Close ()
body, _ := io. ReadAll (resp.Body)
fmt. Println ( string (body))
}
Copy
require 'net/http'
require 'json'
require 'uri'
uri = URI ( "http://127.0.0.1:7783" )
payload = {
"userpass" : "RPC_UserP@SSW0RD" ,
"mmrpc" : "2.0" ,
"method" : "get_token_info" ,
"params" : {
"protocol" : {
"type" : "ERC20" ,
"protocol_data" : {
"platform" : "AVAX" ,
"contract_address" : "0x4f3c5C53279536fFcfe8bCafb78E612E933D53c6"
}
}
}
}
response = Net :: HTTP . post (uri, payload. to_json , 'Content-Type' => 'application/json' )
puts JSON . pretty_generate ( JSON . parse (response. body ))
Show Get Token Info Response Response (success)# {
"mmrpc" : "2.0" ,
"result" : {
"type" : "ERC20" ,
"info" : {
"symbol" : "PNIC" ,
"decimals" : 18
}
},
"id" : null
}
Error Types#
Parameter Type Required Description NoSuchCoin string
–
The specified platform coin was not found or is not activated yet.
Show Error Responses ⚠️ Error Responses# NoSuchCoin# {
"mmrpc" : "2.0" ,
"error" : "No such coin AVAX" ,
"error_path" : "tokens.lp_coins" ,
"error_trace" : "tokens:68] lp_coins:4744]" ,
"error_type" : "NoSuchCoin" ,
"error_data" : {
"coin" : "AVAX"
},
"id" : null
}