Tokens#
- class defichain.node.Tokens(node)#
- burntokens(amounts: str, _from: str, context: str = None, inputs: [{}] = None) str #
Creates (and submits to local node and network) a transaction burning your token (for accounts and/or UTXOs).
The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO’s must belong to the token’s owner (collateral) address
Requires wallet passphrase to be set with walletpassphrase call.
- Parameters:
- Returns:
“hash” (string) – The hex-encoded hash of broadcasted transaction
- Example:
>>> node.tokens.burntokens("10@BTC", "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2")
- createtoken(symbol: str, collateralAddress: str, name: str = None, isDAT: bool = None, decimal: float = None, limit: int = None, mintable: bool = True, tradeable: bool = True, inputs: [{}] = None) str #
Creates (and submits to local node and network) a token creation transaction with given metadata. The second optional argument (may be empty array) is an array of specific UTXOs to spend.
- Parameters:
symbol (str) – (required) Token’s symbol (unique), no longer than 8
collateralAddress (str) – (required) Any valid destination for keeping collateral amount - used as token’s owner auth
name (str) – (optional) Token’s name, no longer than 128
isDAT (bool) – (optional) Token’s ‘isDAT’ property, default is ‘False’
decimal (float) – (optional) Token’s decimal places
limit (int) – (optional) Token’s total supply limit
mintable (bool) – (optional) Token’s ‘Mintable’ property
tradeable (bool) – (optional) Token’s ‘Tradeable’ property
inputs (json array) – (optional) Inputs
- Returns:
“hash” (string) – The hex-encoded hash of broadcasted transaction
- Example:
>>> node.tokens.createtoken("MyToken", "df1qpsg2v3fajhwfrc3dchsqpcwqfegdxpncwpcda2")
- decodecustomtx(hexstring: str, iswitness: bool | None = None) str #
Get detailed information about a DeFiChain custom transaction.
- Parameters:
hexstring (str) – (required) The transaction hex string
iswitness (bool) –
(optional) Whether the transaction hex is a serialized witness transaction.
If iswitness is not present, heuristic tests will be used in decoding.
If true, only witness deserialization will be tried.
If false, only non-witness deserialization will be tried.
This boolean should reflect whether the transaction has inputs (e.g. fully valid, or on-chain transactions), if known by the caller.
- Returns:
{…} (json) – returns decoded custom transaction
{ "txid": (string) The transaction id. "type": (string) The transaction type. "valid" (bool) Whether the transaction was valid. "results" (json object) Set of results related to the transaction type }
- Example:
>>> node.tokens.decodecustomtx("hexstring")
- getcustomtx(txid: str, blockhash: str | None = None) {} #
Get detailed information about a DeFiChain custom transaction. Will search wallet transactions and mempool transaction, if a blockhash is provided and that block is available then details for that transaction can be returned.
-txindex can be enabled to return details for any transaction.
- Parameters:
txid (str) – (required) The transaction id
blockhash (str) – (optional) The block in which to look for the transaction
- Returns:
{…} (json) – returns a custom transaction in json format
{ "type": (string) The transaction type. "valid" (bool) Whether the transaction was valid. "results" (json object) Set of results related to the transaction type "block height" (string) The block height containing the transaction. "blockhash" (string) The block hash containing the transaction. "confirmations": n, (numeric) The number of confirmations for the transaction. }
- example:
>>> node.tokens.getcustomtx("66ea2ac081e2917f075e2cca7c1c0baa12fb85c469f34561185fa64d7d2f9305")
- gettoken(key: str)#
Returns information about token.
- Parameters:
key (str) – (required) One of the keys may be specified (id/symbol/creationTx)
- Returns:
{…} (json) – json object with token information
- Example:
>>> node.tokens.gettoken("DFI")
- listtokens(start: int | None = None, including_start: bool | None = None, limit: int = 100, verbose: bool = True) {} #
Returns information about tokens
- Parameters:
start (int) –
including_start (bool) –
limit (int) –
verbose (bool) –
- Returns:
[{…}] (json array) – json object with token information
- Example:
>>> node.tokens.listtokens()
- minttokens(amounts: str, inputs: [{}] = None) str #
Creates (and submits to local node and network) a transaction minting your token (for accounts and/or UTXOs).
The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO’s must belong to the token’s owner (collateral) address
- Parameters:
amounts (str) – (required) Amount as json string, or array. Example: ‘[ “amount@token” ]’
inputs (json array) – (optional) Inputs
- Returns:
“hash” (string) – The hex-encoded hash of broadcasted transaction
- Example:
>>> node.tokens.minttokens("10@MyToken")
- updatetoken(token: str, symbol: str = None, name: str = None, isDAT: bool = False, mintable: bool = None, tradeable: bool = None, finalize: bool = None, inputs: [{}] = None) str #
Creates (and submits to local node and network) a transaction of token promotion to isDAT or demotion from isDAT. Collateral will be unlocked.
The second optional argument (may be empty array) is an array of specific UTXOs to spend. One of UTXO’s must belong to the token’s owner (collateral) address
- Parameters:
token (str) – (required) The tokens’s symbol, id or creation tx
symbol (str) – (optional) New token’s symbol, no longer than 8
name (str) – (optional) New token’s name, no longer than 128
isDAT (bool) – (optional) Token’s ‘isDAT’ property, default is ‘False’
mintable (bool) – (optional) Token’s ‘Mintable’ property
tradeable (bool) – (optional) Token’s ‘Tradeable’ property
finalize (bool) – (optional) Lock token properties forever
inputs (json array) – (optional) Inputs
- Returns:
“hash” (string) – The hex-encoded hash of broadcasted transaction
- Example:
>>> node.tokens.updatetoken("MyToken", isDAT=True)