ID 1.12.721 in operation_results array defines the operation execution result ID. An object with said ID stores the information about the deployed contract. api.getObject(objectId) method can be used to get said object.
The first element of the contracts_id array is the contract ID. Contract ID is used to call it.
There are two types of contract calls - a call without changing the contract's state (to receive values of variables and methods) and a call that would change the contract's state (sending a transaction).
Get ERC20 Token Balance
Fetching an account's balance in token doesn't require a transaction, hence the callContractNoChangingState(contractId, accountId, assetId, bytecode) method is used:
The last argument in the method is the hash of the contract's called method and the argument joined with the arguments that were passed along with the call. In this case 70a08231 is the hash of balanceOf(address) method, and 0000000000000000000000000000000000000000000000000000000000000536 is the "address" (derived from account ID), the balance of which we need are trying to get (zeroes are added to increase the size of the address to 32 bytes). This address belongs to Echo account 1.2.1334. More information on converting the IDs to address formats can be found in EVM. Introduction .
Transfer ERC20 Token
Token transfer is an operation that requires a transaction.
As a result of the transfer, the contract calls an event Transfer(address indexed from, address indexed to, uint256 value); event. The logs can be viewed via getContractResult method, and adding operation execution result ID to argument:
const result =await echo.api.getContractResult('1.12.727');