VRC25 Exchange/Wallet integration
This tutorial will walk through integrating TRC2 tokens to applications (e.g., wallet, exchange)
Prerequisites
Contract ABI: IVRC25.json
Contract Interface: IVRC25.sol
interface IVRC25 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Fee(address indexed from, address indexed to, address indexed issuer, uint256 value);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function issuer() external view returns (address);
function allowance(address owner, address spender) external view returns (uint256);
function estimateFee(uint256 value) external view returns (uint256);
function transfer(address recipient, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}Users are recommended to refer to the VRC25 Specification for more details about the VRC25 token standard.
Follow the steps below to interact with the smart contract by using the Web3 library and Node.
Initialize Web3 provider
As a first step, we need to initialize a Web3 provider by connecting to Viction Full node RPC endpoint.
Look at the Viction Networks page to get more information of the Viction Testnet/Mainnet RPC network.
Unlock wallet
Unlock the wallet before interacting with VRC25 token contracts
Example
Initialize Web3 VRC25 Contract
Note: Get IVRC21.json here.
Check balance
Call function balanceOf() from VRC25 contract to check the token balance for an address.
Example
Estimate fee
Before sending tokens, we need to check TX fee by calling estimateFee function in VRC25 smart contract.
Example
Note: this fee is the amount of the token that needs to be paid to send the VRC25 token applied to VIC ZeroGas
Transfer token
The Token holder needs to call function transfer to send token to an address.
Example
Checking VIC ZeroGas
Call getTokenCapacity to 0x8c0faeb5c6bed2129b8674f262fd45c4e9468bee. If the return value > 0, the token has successfully been enabled by the VIC ZeroGas protocol.
Last updated