Skip to main content

Token API

import {JsonRpcClient} from '@defichain/jellyfish-api-jsonrpc'
const client = new JsonRpcClient('http://foo:bar@localhost:8554')

// Using client.token.
const something = await client.token.method()

createToken

Creates a token with given metadata.

client.token.createToken()
interface token {
createToken (metadata: CreateTokenMetadata, utxos: UTXO[] = []): Promise<string>
}

interface CreateTokenMetadata {
symbol: string
name: string
isDAT: boolean
mintable: boolean
tradeable: boolean
collateralAddress: string
}

interface UTXO {
txid: string
vout: number
}

updateToken

Updates a token with given metadata.

client.token.updateToken()
interface token {
updateToken (token: string, metadata?: UpdateTokenMetadata): Promise<string>
}

interface UpdateTokenMetadata {
symbol?: string
name?: string
isDAT?: boolean
mintable?: boolean
tradeable?: boolean
finalize?: boolean
}

listTokens

Returns information about tokens.

client.token.listTokens()
interface token {
listTokens (
pagination: TokenPagination = {
start: 0,
including_start: true,
limit: 100
},
verbose = true
): Promise<TokenResult>
}

interface TokenResult {
[id: string]: TokenInfo
}

interface TokenInfo {
symbol: string
symbolKey: string
name: string
decimal: BigNumber
limit: BigNumber
mintable: boolean
tradeable: boolean
isDAT: boolean
isLPS: boolean
isLoanToken: boolean
finalized: boolean
minted: BigNumber
creationTx: string
creationHeight: BigNumber
destructionTx: string
destructionHeight: BigNumber
collateralAddress: string
}

interface TokenPagination {
start: number
including_start: boolean
limit: number
}

getToken

Returns information about token.

client.token.getToken()
interface token {
getToken (symbolKey: string): Promise<TokenResult>
}

interface TokenResult {
[id: string]: TokenInfo
}

interface TokenInfo {
symbol: string
symbolKey: string
name: string
decimal: BigNumber
limit: BigNumber
mintable: boolean
tradeable: boolean
isDAT: boolean
isLPS: boolean
isLoanToken: boolean
finalized: boolean
minted: BigNumber
creationTx: string
creationHeight: BigNumber
destructionTx: string
destructionHeight: BigNumber
collateralAddress: string
}

mintTokens

Creates a transaction to mint tokens.

client.token.mintTokens()
interface token {
mintTokens (amountToken: string, utxos: UTXO[] = []): Promise<string>
}

interface UTXO {
txid: string
vout: number
}

burnTokens

Creates a transaction to burn tokens.

client.token.burnTokens()
interface token {
burnTokens (amounts: string, from?: string, context?: string, utxos: UTXO[] = []): Promise<string>
}

interface UTXO {
txid: string
vout: number
}

getCustomTx

Get detailed information about any custom transaction.

client.token.getCustomTx()
interface token {
getCustomTx (txid: string, blockhash?: string): Promise<GetCustomTxResult | string>
}

interface GetCustomTxResult {
type: string
valid: boolean
results: object
block_height: string
blockhash: string
confirmations: number
}

decodeCustomTx

Get detailed information about any custom transaction from the raw transaction.

client.token.decodeCustomTx()
interface token {
decodeCustomTx (hexstring: string, iswitness?: boolean): Promise<DecodeCustomTxResult | string>
}

interface DecodeCustomTxResult {
txid: string
type: string
valid: boolean
results: object
}