Token
Facilitate a simple interface to work with a special case of Ethereum smart contracts, with a common ERC20 interface. ERC20 is a standard smart contract template for Ethereum fungible tokens. More info here.
To work with this token, we need to deploy an ERC20 contract. To operate with the contract, we can register it in Hancock, (anyway we can use all operations with any deployed contract, if we add "smartContractAddress" parameter in body request, with the contract address on it, and delete {AddressAlias} parameter in path).
Register
We can register this kind of contracts, with the address of the contract and an alias only. You can see the technical documentation, and an example of the call here.
Once we register the contract, we can get the complete list of ERC20 contracts registered in Hancock with this call.
Metadata
To know all details about a contract make this call.
This gives us the common data about this kind of contracts:
- Name: Name of the token.
- Symbol: Abbreviation to identify the token.
- Decimals: Accuracy of the unit of measurement of the token.
- TotalSupply: Total amount of tokens available.
Balance
The first action with our contract will be to know our current tokens balance. We only need a simple API call to get it. You can see the technical documentation, and an example of the call here.
Transfer
You can make a transfer of an amount of your balance from your account to a specific account. You only need to have enough tokens to make the transfer.
This operation gives us a response with everything you need to sign and send to an Ethereum DLT. More info and an example here.
Approve
This operation allows the owner to approve a specific amount of tokens for the spender. This spender can perform the "transferFrom" operation until the maximum amount is approved.
This operation gives us a response with everything you need to sign and send to a Ethereum DLT. More info and an example here.
Allowance
To consult the amount of tokens (approved by the owner) that can be transfer with a "transferFrom" operation from the spender's account, you need to call this operation, that returns the amount of approved value. More info and an example here.
Transfer from
You can use "transferFrom" operation to transfer tokens from an account with enough token balance to a specific account. The spender that invokes the operation must have sufficient allowance to transfer. More info and an example here.
Remember that after getting the response, we can send the response to sign, and send it to DLT network. You can use the Wallet-Hub component to finish the operations.