TRC-20 Contracts
trident-java encapsulates standard TRC-20 methods in core.contract.Trc20Contract
.
For standard TRC-20 methods, refer to TIP-20.
Before Start
A Trc20Contract
instance works with ApiWrapper
. Refer to Quickstart for instructions of initialization.
Also, the address of the contract and the caller's address are required.
Apiwrapper wrapper = new Apiwrapper(params..);
//Apiwrapper wrapper = Apiwrapper.ofMainnet()/ofShasta()/ofNile()
//This is core.contract.Contract, not from the proto
Contract contract = wrapper.getContract("contract address");
Trc20Contract token = new Trc20Contract(contract, "caller's address", wrapper);
Name
token.name();
Symbol
token.symbol()
Decimals
token.decimals()
TotalSupply
token.totalSupply();
BalanceOf
token.balanceOf("holder address");
Transfer
token.transfer("receiver's address", amount, power, "memo", feeLimit);
TransferFrom
//the method of transferFrom usually works as a withdraw function
token.transferFrom("from address", "receiver's address", amount, power, "memo", feeLimit);
Approve
token.approve("spender's address", amount, power, "memo", feeLimit);
GetAllowance
token.allowance("from address", "spender's address");
Updated over 3 years ago