Viction
  • Getting Started
  • General
    • Overview
    • Viction Blockchain
      • PoSV Consensus
      • Comparison
    • Staking
      • Staking Requirements
      • Staking Rewards
      • How to stake on Viction Wallet
    • Network Information
      • Viction Mainnet
      • Viction Testnet
    • Viction RPC API
  • Smart Contract Development
    • Solidity
      • A Simple Smart Contract
      • Solidity by Example
    • Standards & Specification
      • VRC25 Specification
      • VRC725 Specification
    • IDEs and Tools
      • Remix
      • Ethers.js
      • web3.js
      • thirdweb CLI
    • Deployment & Verification
      • Hardhat
      • Foundry
  • DApp Development
    • Integration
      • Exchange/Wallet integration
      • VRC25 Exchange/Wallet integration
      • Viction Staking Governance
      • VIC ZeroGas
      • VRRF
    • Data and analytics
    • Embedded Wallet (MPC)
    • Walkthrough: Build a Dapp on Viction
      • Setup Environment
      • Write the Smart Contract
      • Interacting with the Dapp in a browser
  • Masternode
    • Requirements
    • Run a Full Node
      • Binary
      • Create a Viction Masternode
      • Tmn
      • Docker
    • Apply Your Node
    • Slashing Mechanism
    • Chain Data Snapshots
    • Troubleshooting
  • Viction Wallet
    • User Guide
      • Authentication
      • How to create a new wallet
      • How to restore a wallet?
      • Wallet settings
      • Send & Receive Tokens
      • Add custom token
      • Manage Tokens
      • Send NFT
      • General settings
    • Developer Guide
    • Privacy Policy
    • Term and Services
  • Viction Bridge
    • Spacegate
    • Arken Bridge
    • Hyperlane
  • Viction Data Availability
    • Viction DA RPC API
    • DA Integration Use cases
      • Simple Guide for Integrating OP Stack Rollup with Viction DA Layer
  • How to
    • How to Connect to Viction Blockchain
      • Coin98 Super Wallet
      • Metamask
      • Ledger
    • How to troubleshoot when the node is up but couldn't begin to sync block
    • How to Vote for Viction Saigon Network Upgrade Proposal
    • How to issue a token via VICIssuer
    • How to verify if a contract has been issued via VICIssuer
    • How to deploy the VRC725 contract
    • How to apply ZeroGas for VRC725 contract
    • How to Migrate Dapps from Ethereum
    • How to register Token or NFT logo on Vicscan
    • How to verify a contract on Vicscan
    • How to confirm a project on Vicscan
    • How to check if a token is gas sponsored on Viction
    • How to verify gas sponsored transactions
    • How to create Telegram Mini Apps
    • How to use VictionSafe (Multisig)
  • FAQ
    • APIs
    • General
      • Viction
      • Ecosystem
      • VIC - Economics
      • Contact & Support
    • Masternodes and Voting
      • Masternodes
      • Voter
    • Products
      • VicScan (Explorer)
      • VicMaster
      • VicStats
      • VicIssuer
        • How to Verify & Publish Contract Source Code on VicScan
      • Viction Wallet
      • Viction Data Availability Network
  • Legal
    • Terms of Use
    • Privacy Policy
  • Whitepaper and Research
  • Archive
    • TOMOE
    • How to Deploy a VRC25 Token on Viction
    • How to deploy an ICO smart contract on Viction
    • How to deploy an NFT token
    • An Example of Building a Dapp on Viction
    • Migrate Ethereum Dapp to Viction
    • TomoMasterDAO
      • Introduction
      • Governance model
        • On-Chain vs Off-Chain Voting
        • Board
        • Proposals
        • Voting and Outcome
      • Tokenomics
      • How to utilize and trade tDAO
      • Proposal guidelines for TomoMasterDAO
    • Old Viction Testnet
    • Deploy on Viction
      • CLI Commands
      • Viction Private Testnet Setup
Powered by GitBook
On this page
  • Prerequisites
  • Initialize Web3 provider
  • Unlock wallet
  • Initialize Web3 VRC25 Contract
  • Check balance
  • Estimate fee
  • Transfer token
  • Checking VIC ZeroGas
  1. DApp Development
  2. Integration

VRC25 Exchange/Wallet integration

This tutorial will walk through integrating TRC2 tokens to applications (e.g., wallet, exchange)

PreviousExchange/Wallet integrationNextViction Staking Governance

Last updated 1 year ago

Prerequisites

Contract ABI:

Contract Interface:

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 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.

const Web3 = require('web3')
const web3 = new Web3('https://rpc.viction.xyz')
const chainId = 88

Unlock wallet

Unlock the wallet before interacting with VRC25 token contracts

Example

// Unlock wallet by private key
const account = web3.eth.accounts.privateKeyToAccount(pkey)
const holder = account.address
web3.eth.accounts.wallet.add(account)
web3.eth.defaultAccount = holder

Initialize Web3 VRC25 Contract

const trc25Abi = require('./IVRC25.json')
const address = '[enter_your_contract_address]'
const trc25 = new web3.eth.Contract(trc25Abi,
        address, {gasPrice: 250000000, gas: 2000000 })

Check balance

Call function balanceOf() from VRC25 contract to check the token balance for an address.

Example

trc25.methods.balanceOf(holder).call()
.then((result) => {
    console.log(result)
}).catch(e => console.log(e))

Estimate fee

Before sending tokens, we need to check TX fee by calling estimateFee function in VRC25 smart contract.

Example

trc25.methods.estimateFee().call()
.then((result) => {
    console.log(result)
}).catch(e => console.log(e))

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

// send 500000000000000000000 tokens to this address (e.g decimals 18)
const to = "0xf8ac9d5022853c5847ef75aea0104eed09e5f402"
trc25.methods.transfer(to, '500000000000000000000').send({
    from: holder,
    gas: 2000000,
    gasPrice: 250000000,
    chainId: chainId
})
.then((result) => {
    console.log(result)
}).catch(e => console.log(e))

Checking VIC ZeroGas

Look at the page to get more information of the Viction Testnet/Mainnet RPC network.

Note: Get IVRC21.json .

Call getTokenCapacity to . If the return value > 0, the token has successfully been enabled by the VIC ZeroGas protocol.

IVRC25.json
IVRC25.sol
VRC25 Specification
Viction Networks
here
0x8c0faeb5c6bed2129b8674f262fd45c4e9468bee