KRC20

constructor

Params

Name

Type

Required

Description

client

Client

Required

RPC client that will be used to interact with KardiaChain

address

string

KRC20 smart contract address

name

string

KRC20 token name

symbol

string

KRC20 token symbol

decimals

number

KRC20 token decimals

abi

object[]

Custom ABI

Return

Return an KRC20 instance .

Methods

setCustomABI

Set custom ABI for KRC20

Params

Name

Type

Required

Description

abi

object[]

Required

Custom ABI

Only use this method when you're sure about your ABI

Return

None

getName

Get token's name

Params

Name

Type

Required

Description

fetch

boolean

Indicate if should fetch from blockchain or get from local cache.

If fetch is set to true, data from blockchain will also be saved to local cache for future use.

Return

Token's name

getDecimals

Get token's decimals

Params

Name

Type

Required

Description

fetch

boolean

Indicate if should fetch from blockchain or get from local cache.

If fetch set to true, data from blockchain will also be saved to local cache for future use.

Return

Token's decimals

getSymbol

Get token's symbol

Params

Name

Type

Required

Description

fetch

boolean

Indicate if should fetch from blockchain or get from local cache.

If fetch set to true, data from blockchain will also be saved to local cache for future use.

Return

Token's symbol

getTotalSupply

Get token's total supply

Params

Name

Type

Required

Description

format

string or BigNumber or

number

Return format. Default is string

Return

Token's total supply

getFromAddress

Get token data from blockchain and save to local cache

Params

Name

Type

Required

Description

address

string

Required

Token address

Return

None

balanceOf

Get token balance of an address

Params

Name

Type

Required

Description

address

string

Required

Address to check balance

Return

Token balance of address

Balance should be parse with token's decimals to get correct display value

transfer

Transfer token to another address

Params

Name

Type

Required

Description

privateKey

string

Required

Private key to sign the transaction

to

string

Required

Receiver's address

amount

number

Required

Amount to transfer

transferPayload

object

Custom payload for transaction object.

waitUntilMined

boolean

Indicate if wait for transaction to be executed successfully or return transaction hash immediately

transferRaw

Transfer token to another address

Params

Name

Type

Required

Description

privateKey

string

Required

Private key to sign the transaction

to

string

Required

Receiver's address

amount

string

Required

Padded amount of token to transfer

transferPayload

object

Custom payload for transaction object.

waitUntilMined

boolean

Indicate if wait for transaction to be executed successfully or return transaction hash immediately

estimateGas

Estimate gas for KRC20 transaction

Params

Name

Type

Required

Description

to

string

Required

Receiver's address

amount

number

Required

Amount to transfer

Return

Estimated gas for transaction

Last updated