Tokens
The Tokens Module enables support for the on-chain creation of colored coins, also called tokens. The created tokens are typically used with another module that supports operations on tokens. For example, the Assets Module provides buy/sell operations for tokens
.
Tokens can be generated on any chain where the ac_cc parameter is enabled.
The tokens
module requires locking a proportional amount of the native coins. Each satoshi of the native coin is equal to one token within the total supply.
tokenaddress (pubkey)
The tokenaddress
method returns information about a token address according to a specific pubkey
. If no pubkey
is provided, the pubkey
used to launch the daemon is the default.
Name | Type | Description |
---|---|---|
pubkey | (string, optional) | the pubkey of the desired address |
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed successfully |
TokensCCaddress | (string) | taking the token contract's EVAL code as a modifier, this is the public address that corresponds to the token contract's privkey, also known as Tokens CC's global address |
myCCaddress | (string) | taking the token contract's EVAL code as a modifier, this is the Tokens Antara address from the pubkey of the user |
myaddress | (string) | the normal public address of the pubkey used to launch the chain |
Command:
./komodo-cli -ac_name=HELLOWORLD tokenaddress 028702e30d8465d6aa85f35d2f58c06a6ee17f23f376b56044dadf7b793f2c12b9
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokenaddress", "params":["028702e30d8465d6aa85f35d2f58c06a6ee17f23f376b56044dadf7b793f2c12b9"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
tokenbalance tokenid (pubkey)
The tokenbalance
method checks the token balance according to a provided pubkey
. If no pubkey
is provided, the pubkey
used to launch the daemon is the default.
Name | Type | Description |
---|---|---|
tokenid | (string) | the txid that identifies the token |
pubkey | (string) | the pubkey for which to examine the balance; if no pubkey is provided, the pubkey used to launch the daemon is the default |
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed succesfully |
CCaddress | (string) | taking the token contract's EVAL code as a modifier, this is the CC address from the pubkey of the user |
tokenid | (string) | the txid that identifies the token |
balance | (number) | the balance of the address that corresponds to the pubkey |
Command:
./komodo-cli -ac_name=HELLOWORLD tokenbalance c5bbc34e6517c483afc910a3b0585c40da5c09b7c5d2d9757c5c5075e2d41b59
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokenbalance", "params":["c5bbc34e6517c483afc910a3b0585c40da5c09b7c5d2d9757c5c5075e2d41b59"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
Check the token balance of a specific pubkey
./komodo-cli -ac_name=HELLOWORLD tokenbalance c5bbc34e6517c483afc910a3b0585c40da5c09b7c5d2d9757c5c5075e2d41b59 028bb4ae66aa4f1960a4aa822907e800eb688d9ab2605c8067a34b421748c67e27
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokenbalance", "params":["c5bbc34e6517c483afc910a3b0585c40da5c09b7c5d2d9757c5c5075e2d41b59" ,"028bb4ae66aa4f1960a4aa822907e800eb688d9ab2605c8067a34b421748c67e27"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
tokencreate name supply description
The tokencreate
method creates a new token.
For every token created, the method requires one satoshi of the parent blockchain's coins. For example, 1 COIN
of the blockchain provides 100000000
tokens.
The method returns a hex-encoded transaction which should then be broadcast using sendrawtransaction
.
sendrawtransaction
then returns a txid
, which is your tokenid
.
A non-fungible token contains an additional array of data describing its corresponding asset. The data has an eval code which binds this non-fungible token to an Antara Module responsible for validation.
To create a non-fungible token, use only 1 satoshi.
To create a token that can be divided and transferred in fractional amounts, this must be handled on the application side of development.
To create a token that is divisible to one decimal place, for example, consider 10 tokens as a single unit. Sending one satoshi's worth of the token is the equivalent of sending one decimal point of the actual token.
Name | Type | Description |
---|---|---|
name | (string) | the proposed name of the token |
supply | (number) | the amount of coins used to create the tokens |
description | (string) | the description of the token |
Name | Type | Description |
---|---|---|
result | (string) | whether the command succeeded |
hex | (string) | a raw transaction in hex-encoded format; you must broadcast this transaction to complete the command |
Command:
./komodo-cli -ac_name=HELLOWORLD tokencreate TOK 0.00000100 "creating a TOK token"
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokencreate", "params":["TOK" ,"0.00000100" ,"creating a TOK token"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
Step 2: Broadcast the raw transaction hex
./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 0400008085202f8901065bc4522b82396e01b03ecf30abe9b7599621d861ad844818c87ac691005e18000000004847304402201f162ee2f8dac7382ff871d2aa7eb304d315eeb352c3d3464c36af8c9453273c0220074ae39178df09c13836ef1f8b647ffe3db4e7e1b428cc734a05e53707541db801ffffffff041027000000000000302ea22c8020432de388aabcb6b4e3326351d1d815cee8be9a8d37b055cd1c0cf8782e5c50c08103120c008203000401cc6400000000000000302ea22c80205dcc33b0b3f0573b306ab85ffa9ce8622fbcb81cb6ad8ec00f366935bbf500f78103120c008203000401cc7c950b5402000000232102d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b47567ac00000000000000003f6a3df2632102d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b4756703544f4b146372656174696e67206120544f4b20746f6b656e00000000370100000000000000000000000000
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"sendrawtransaction", "params":["0400008085202f8901065bc4522b82396e01b03ecf30abe9b7599621d861ad844818c87ac691005e18000000004847304402201f162ee2f8dac7382ff871d2aa7eb304d315eeb352c3d3464c36af8c9453273c0220074ae39178df09c13836ef1f8b647ffe3db4e7e1b428cc734a05e53707541db801ffffffff041027000000000000302ea22c8020432de388aabcb6b4e3326351d1d815cee8be9a8d37b055cd1c0cf8782e5c50c08103120c008203000401cc6400000000000000302ea22c80205dcc33b0b3f0573b306ab85ffa9ce8622fbcb81cb6ad8ec00f366935bbf500f78103120c008203000401cc7c950b5402000000232102d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b47567ac00000000000000003f6a3df2632102d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b4756703544f4b146372656174696e67206120544f4b20746f6b656e00000000370100000000000000000000000000"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
Step 3 (Optional): Use decoderawtransaction to verify the output is sane
./komodo-cli -ac_name=HELLOWORLD decoderawtransaction 01000000012c223cfc9c3349aed24ca89e44af6fcdb030150443bd6ac55e2080ce4b097c300200000049483045022100dc83b88f5ed1f01aab7dee8bd8f2b3c0bf83537c9b3cbb0c6ea78ebafdf4c6f60220518440e7f43d24c5733531a8d5a825dbb90e716f7ba20c0d469e7004c1fcc5aa01ffffffff0400ca9a3b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc1027000000000000232102adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702acc055cbbe15090000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000396a37e3632103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc0354414b0e54657374696e672070686173652e00000000
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"decoderawtransaction", "params":["01000000012c223cfc9c3349aed24ca89e44af6fcdb030150443bd6ac55e2080ce4b097c300200000049483045022100dc83b88f5ed1f01aab7dee8bd8f2b3c0bf83537c9b3cbb0c6ea78ebafdf4c6f60220518440e7f43d24c5733531a8d5a825dbb90e716f7ba20c0d469e7004c1fcc5aa01ffffffff0400ca9a3b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc1027000000000000232102adf84e0e075cf90868bd4e3d34a03420e034719649c41f371fc70d8e33aa2702acc055cbbe15090000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000396a37e3632103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc0354414b0e54657374696e672070686173652e00000000"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
tokeninfo tokenid
The tokeninfo
method reveals information about any token.
Name | Type | Description |
---|---|---|
tokenid | (string) | the txid that identifies the token |
Name | Type | Description |
---|---|---|
result | (string) | whether the command executed successfully |
tokenid | (string) | the identifying txid for the token id |
owner | (string) | the identifying pubkey of the token creator |
name | (string) | the name of the token |
supply | (number) | the total supply of the token |
description | (string) | the token description provided by the owner at token creation |
data | (string,optional) | the data related to the non-fungible token, in hex |
IsImported | (string,optional) | if 'yes' this token was imported from another chain |
sourceChain | (string,optional) | the name of the imported token's source chain |
sourceTokenId | (string,optional) | for an imported token, the tokenid of the source token on the source chain |
Command:
./komodo-cli -ac_name=HELLOWORLD tokeninfo 43850dfce744581ef44775086625745adecd628993c5ff4c1c786cfd21009add
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokeninfo", "params":["43850dfce744581ef44775086625745adecd628993c5ff4c1c786cfd21009add"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
tokenlist
The tokenlist
method lists all available tokens on the smart chain.
Name | Type | Description |
---|---|---|
(none) |
Name | Type | Description |
---|---|---|
tokenid | (array of strings) | the identifying txid for the token id |
Command:
./komodo-cli -ac_name=HELLOWORLD tokenlist
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokenlist", "params":[]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
tokentransfer tokenid destpubkey amount
The tokentransfer
method transfers tokens from one Antara Address to another.
It is similar to the sendmany method used to send coins on the parent chain.
The method returns a raw hex, which must be broadcast using sendrawtransaction to complete the command.
The source txid/vout
needs to be specified as it is critical to match
outputs with inputs.
A token may be burned by using tokentransfer
to send to a burn address.
Name | Type | Description |
---|---|---|
tokenid | (string, optional) | the identifying txid for the token id |
destpubkey | (string) | the pubkey where the tokens should be sent |
amount | (number) | the number of tokens to send |
Name | Type | Description |
---|---|---|
result | (string) | whether the command succeeded |
hex | (string) | a raw transaction in hex-encoded format; you must broadcast this transaction to complete the command |
Step 1: Create the rawtransaction
./komodo-cli -ac_name=HELLOWORLD tokentransfer e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc66 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 500000
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"tokentransfer", "params":["e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc66" ,"02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92" ,"500000"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
Step 2: Broadcast using sendrawtransaction
./komodo-cli -ac_name=HELLOWORLD sendrawtransaction 01000000023b61e44ce3cedf536b52d8da11faacd041494a078e971551ed4e2bd496bc8da1000000006a4730440220111c67172740c0c2556979fdf84639ba299ff22586ebd220f25aa301f029003f02203da97a2575c0ed1b309774309f5dc952ee305a46cd83e95eae99e3564a1772f6012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff66cc65f38d7e878d312386777c4f049f738b8894353c30108f7fe4ca515489e4000000007b4c79a276a072a26ba067a565802103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc8140c875a14edcbece61a6c18721398c927dc1e4509863e075b3922a8e3a2da6848e037142436e9102b529ee93a9ec618a4c67b63c52790d71812bb94179056913bba100af038001e3a10001ffffffff0420a1070000000000302ea22c8020541be9f843b476373fc18d8c8fab59c98c2c009f49c07fa66b7b431e4142feae8103120c008203000401cce028933b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc28b9486cb2430000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000246a22e374e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc6600000000
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"sendrawtransaction", "params":["01000000023b61e44ce3cedf536b52d8da11faacd041494a078e971551ed4e2bd496bc8da1000000006a4730440220111c67172740c0c2556979fdf84639ba299ff22586ebd220f25aa301f029003f02203da97a2575c0ed1b309774309f5dc952ee305a46cd83e95eae99e3564a1772f6012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff66cc65f38d7e878d312386777c4f049f738b8894353c30108f7fe4ca515489e4000000007b4c79a276a072a26ba067a565802103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc8140c875a14edcbece61a6c18721398c927dc1e4509863e075b3922a8e3a2da6848e037142436e9102b529ee93a9ec618a4c67b63c52790d71812bb94179056913bba100af038001e3a10001ffffffff0420a1070000000000302ea22c8020541be9f843b476373fc18d8c8fab59c98c2c009f49c07fa66b7b431e4142feae8103120c008203000401cce028933b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc28b9486cb2430000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000246a22e374e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc6600000000"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/
Step 3: Decode the raw transaction and check against the following if the data is sane
./komodo-cli -ac_name=HELLOWORLD decoderawtransaction 01000000023b61e44ce3cedf536b52d8da11faacd041494a078e971551ed4e2bd496bc8da1000000006a4730440220111c67172740c0c2556979fdf84639ba299ff22586ebd220f25aa301f029003f02203da97a2575c0ed1b309774309f5dc952ee305a46cd83e95eae99e3564a1772f6012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff66cc65f38d7e878d312386777c4f049f738b8894353c30108f7fe4ca515489e4000000007b4c79a276a072a26ba067a565802103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc8140c875a14edcbece61a6c18721398c927dc1e4509863e075b3922a8e3a2da6848e037142436e9102b529ee93a9ec618a4c67b63c52790d71812bb94179056913bba100af038001e3a10001ffffffff0420a1070000000000302ea22c8020541be9f843b476373fc18d8c8fab59c98c2c009f49c07fa66b7b431e4142feae8103120c008203000401cce028933b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc28b9486cb2430000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000246a22e374e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc6600000000
You can find your rpcuser
, rpcpassword
, and rpcport
in the coin's .conf file.
Command:
curl --user $rpcuser:$rpcpassword --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method":"decoderawtransaction", "params":["01000000023b61e44ce3cedf536b52d8da11faacd041494a078e971551ed4e2bd496bc8da1000000006a4730440220111c67172740c0c2556979fdf84639ba299ff22586ebd220f25aa301f029003f02203da97a2575c0ed1b309774309f5dc952ee305a46cd83e95eae99e3564a1772f6012103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcffffffff66cc65f38d7e878d312386777c4f049f738b8894353c30108f7fe4ca515489e4000000007b4c79a276a072a26ba067a565802103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abc8140c875a14edcbece61a6c18721398c927dc1e4509863e075b3922a8e3a2da6848e037142436e9102b529ee93a9ec618a4c67b63c52790d71812bb94179056913bba100af038001e3a10001ffffffff0420a1070000000000302ea22c8020541be9f843b476373fc18d8c8fab59c98c2c009f49c07fa66b7b431e4142feae8103120c008203000401cce028933b00000000302ea22c8020bc485b86ffd067abe520c078b74961f6b25e4efca6388c6bfd599ca3f53d8dae8103120c008203000401cc28b9486cb2430000232103fe754763c176e1339a3f62ee6b9484720e17ee4646b65a119e9f6370c7004abcac0000000000000000246a22e374e4895451cae47f8f10303c3594888b739f044f7c778623318d877e8df365cc6600000000"]}' -H 'content-type: text/plain;' http://127.0.0.1:$rpcport/