Take the USDT contract on Shasta test net as an example,Use Tronweb and wallet-cli to call the TRC-20 interface of the contract, respectively.
Some related links: [Find the USDT on Tronscan](🔗) [Code conversion tool](🔗)
We can use the `triggersmartcontract
` function to call constant functions in the contract to get the result directly without broadcasting.
Please set `supportConstant
` = true in your node config.
# name
Call the name function to get the name of the token.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli Example:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format
# symbol
Call the symbol function to get the symbol of the token.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli Example:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format
# decimals
Call the decimals function to get the precision of the token.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli Example:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format
# totalSupply
Call the totalSupply function to get the total supply of the token.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format
# balanceOf
Call the balanceOf function to get the token balance of the specified account.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli Example:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format
# transfer
Call transfer function for token transfer
**HTTP API : **
The parameter is to encode address and uint256 in transfer (address,uint256), please refer to [the parameter encoding and decoding document](🔗) Note: After calling this HTTP API, you also need to call the signature and broadcast APIs.
**Tronweb Example:**
**Wallet-cli Example:**
**Usage :** TriggerContract [ownerAddress] [contractAddress] [method] [args] [isHex] [fee_limit] [value] [token_value] [token_id] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format fee_limit: the maximum trx consumption of this calling, the unit is sun value: the amount of TRX that transfered to the contract while calling the contract, the unit is sun token_value: the amount of TRC10 asset that transfered to the contract while calling the contract token_id:the TRC10 asset ID that transfered to the contract while calling the contract
Transaction confirmation: Check whether the transfer of TRC20 was successful according to result of getTransactionInfoById.
# approve
Call the approve function to authorize a certain amount of token use rights to other addresses.
**HTTP API : **
Note: After calling this HTTP API, you also need to call the signature and broadcast APIs.
**Tronweb Example:**
**Wallet-cli Example:**
**Usage :** TriggerContract [ownerAddress] [contractAddress] [method] [args] [isHex] [fee_limit] [value] [token_value] [token_id] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format fee_limit: the maximum trx consumption of this calling, the unit is sun value: the amount of TRX that transfered to the contract while calling the contract, the unit is sun token_value: the amount of TRC10 asset that transfered to the contract while calling the contract token_id:the TRC10 asset ID that transfered to the contract while calling the contract
Transaction confirmation: Check whether the transfer of TRC20 was successful according to result of getTransactionInfoById.
# transferFrom
Authorized addresses calling the transferFrom function to transfer tokens from autherizer's account.
**HTTP API : **
Note: After calling this HTTP API, you also need to call the signature and broadcast APIs.
**Tronweb Example:**
**Wallet-cli Example:**
**Usage :** TriggerContract [ownerAddress] [contractAddress] [method] [args] [isHex] [fee_limit] [value] [token_value] [token_id] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format fee_limit: the maximum trx consumption of this calling, the unit is sun value: the amount of TRX that transfered to the contract while calling the contract, the unit is sun token_value: the amount of TRC10 asset that transfered to the contract while calling the contract token_id:the TRC10 asset ID that transfered to the contract while calling the contract
Transaction confirmation: Check whether the transfer of TRC20 was successful according to result of getTransactionInfoById.
# allowance
Authorized addresses call the allowance function to query the balance of authroized amount.
**HTTP API : **
**Tronweb Example:**
**Wallet-cli Example:**
**Usage : **TriggerConstantContract [ownerAddress] [contractAddress] [method] [args] [isHex] **Parameter Description:** ownerAddress: calller address contractAdress:TRC20 contract address method: contract function args:function parameters,If there is no parameter,use # placeholder isHex: whether the address of the command parameter is in hex format