Returns the amount of tokens approved by the owner that can be transferred to the spender's account
The caller's address
The token owner's address
The token spender's address
Address or alias of the token smart contract registered in Hancock
The result of the request
Token owner can approve for spender
to transferFrom(...) tokens
from the token owner's account
The token owner's address
The token spender's address
The amount of tokens to transfer (in weis)
Address or alias of the token smart contract registered in Hancock
Configuration of how the transaction will be send to the network
The result of the request
Get the list of all tokens registered in Hancock
The list of all tokens registered in Hancock
Get the token balance for account tokenOwner
Address or alias of the token smart contract registered in Hancock
The token owner's address
The result of the request with the balance
Retrieves the metadata of the token
Address or alias of the token smart contract registered in Hancock
name, symbol, decimals, and totalSupply of the token
Register a new ERC20 token instance in Hancock
An alias for the token
The address of the deployed smart contract token instance
The result of the request
Transfer the balance from token owner's account to to
account
The token sender's address
The token receiver's address
The amount of tokens to transfer (in weis)
Address or alias of the token smart contract registered in Hancock
Configuration of how the transaction will be send to the network
The result of the request
Transfer tokens
from the sender
account to the to
account
The calling account must already have sufficient tokens approved for spending from the sender
account and
The aproved spender's address
The token sender's address
The token receiver's address
The amount of tokens to transfer (in weis)
Address or alias of the token smart contract registered in Hancock
Configuration of how the transaction will be send to the network
The result of the request
Generated using TypeDoc
HancockEthereumTokenService
Introduction
We can use this interface to manage operations related with ERC20 Ethereum tokens over blockchain
Token registration
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.register( 'token-contract-alias', '0x28a0686efb7dd9b625288a08649a6278cc4fd154' ); console.log(result);
Console output:
{ success: true }
Transfer token
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.transfer( '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', '0x28a0686efb7dd9b625288a08649a6278cc4fd154', 250000000, 'token-contract-alias', { privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83' } ); console.log(result);
Console output:
{ success: true }
Transfer token from
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.transferFrom( '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', '0x28a0686efb7dd9b625288a08649a6278cc4fd154', '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e', 250000000, 'token-contract-alias', { privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83' } ); console.log(result);
Console output:
{ success: true }
Allowance to transfer tokens
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.allowance( '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e', '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e', ); console.log('allowance: ' + result);
Console output:
Get token balance
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.getBalance( 'contract-alias', '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e' ); console.log(result);
Console output:
{ balance: "120000000000000000", decimals: 18 }
Get token balance
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.getBalance( 'contract-alias', '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e' ); console.log(result);
Console output:
{ balance: "120000000000000000", decimals: 18 }
Approve transfer
const hancockEthClient = new HancockEthereumClient(config); const result = await hancockEthClient.token.approve( '0x6c0a14f7561898b9ddc0c57652a53b2c6665443e', '0x34C54CB0d5cD1c0f5240324618adAD15ad6646AF', '3', 'contract-alias', { privateKey: '0xd06026d5b8664036bdec0a924b8c7360566e678a2291e9440156365b040a7b83' } ); console.log(result);
Console output:
{ success: true }