Skip to main content

Web3

web3.addr

web3.addr.getBalance(address: string)

const balance = await web3.addr.getBalance('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm')
// '1000000000000000000000'

web3.addr.getISN(address: string)

const isn = await web3.addr.getISN('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm')
// 1

web3.addr.getAddressTokens(address: string)

const tokens = await web3.addr.getAddressTokens('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm')
tokens = [{
TokenID: '5789767',
Address: 'GXX:token',
Symbol: 'GXX',
TokenState: 0,
Decimals: 8,
Amount: '3018154202998548',
StateHeight: 294558
}]

web3.addr.getAddressTokenBalance(address: string, token: string)

const tokenbalance = await web3.addr.getAddressTokenBalance('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm', 'FXX')
// '1000000000000000000000'

web3.addr.getAddressInfo(address: string)

const info = await web3.addr.getAddressInfo('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm')
info = {
Address: 'eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm:ed25519',
ShardOrder: 2,
ShardIndex: 2,
State: {
Metadata: {
Name: 'address Name',
Description: 'address Description',
IconUrl: 'address Icon'
Website: 'https://address.website.com',
Social: {
Github: string
Discord: string
Twitter: string
Telegram: string
Facebook: string
Email: string
}
}
}
}

web3.addr.getTxnListByAddress(address: string)

const txnList = await web3.addr.getTxnListByAddress('eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm')
txnList = {
TotalNum: 404,
ListData: DIOX.TxSummary[]
}

web3.txn

web3.txn.sign(txdata: OriginalTxn, secretKey: string)

const txn = await web3.txn.sign(
{
sender: 'eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm:ed25519',
gasprice: 100,
function: 'core.wallet.transfer',
args: {
Amount: '10000000000',
To: 'qzysdapqk4q3442fx59y2ajnsbx5maz3d6japb7jngjrqq5xqddh60n420:ed25519',
TokenId: 'GXX',
},
},
secretKeyArray,
)
tx = {
rawTxData: base64rawdata,
hash: 'wkapenmgkqre483cg344a8bxstrq4nsj1matcdmtjna03tcmkc10'
}

web3.txn.send(originalTxn: OriginalTxn, secretKey: string)

const txHash = await web3.txn.send(
{
sender: 'eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm:ed25519',
gasprice: 100,
function: 'core.wallet.transfer',
args: {
Amount: '10000000000',
To: 'qzysdapqk4q3442fx59y2ajnsbx5maz3d6japb7jngjrqq5xqddh60n420:ed25519',
TokenId: 'GXX',
},
},
secretKeyArray,
)
// wkapenmgkqre483cg344a8bxstrq4nsj1matcdmtjna03tcmkc10

web3.txn.getTxn(hash: string)

const txn = await web3.txn.getTxn('wkapenmgkqre483cg344a8bxstrq4nsj1matcdmtjna03tcmkc10')
// DIOX.TxDetail

web3.txn.getEstimatedFee(originTxn: OriginalTxn)

const txn = await web3.txn.getEstimatedFee({
sender: 'eqfkk71rg18mcjcp63tkcz4xpcxd91wtd5atpwk82j2jmcdeb50j6es2xm:ed25519',
gasprice: 100,
function: 'core.wallet.transfer',
args: {
Amount: '10000000000',
To: 'qzysdapqk4q3442fx59y2ajnsbx5maz3d6japb7jngjrqq5xqddh60n420:ed25519',
TokenId: 'GXX',
},
})
// 95500

web3.txn.sendRawTx(rawTxData: string)

const txnHash = await web3.txn.sendRawTx(base64rawData)
// txnHash