VRC-20 contract interaction

Query account VRC-20 balance

const VisionWeb = require("visionweb");
const HttpProvider = VisionWeb.providers.HttpProvider;


const PrivateKey = "your private key";
const FullNode = new HttpProvider("https://vpioneer.infragrid.v.network/");
const SolidityNode = new HttpProvider("https://vpioneer.infragrid.v.network/");
const EventServer = new HttpProvider("https://vpioneer.infragrid.v.network/");

const VisionWeb = new VisionWeb(FullNode, SolidityNode, EventServer, PrivateKey);
const contractObj = require('./BasicToken.json');
const abi = contractObj.abi;
const bytecode = contractObj.bytecode;


// invoke contract
(async function () {
  // contract address
  const contract = await VisionWeb.contract().at("46e2d145ebd0d991f607b4badfb0fa14435a1efe3a");
  // console.log(contract)
  // search balance
  const res = await contract.balanceOf("463a86B966369B5c98F0f7E0B009F4D2aBD4d97162").call();
  console.log(Number(res))

})();

node .\vtest-testbalanceof.js

Successful execution can return the account balance:

788788

transfer

const VisionWeb = require("visionweb");
const HttpProvider = VisionWeb.providers.HttpProvider;

const PrivateKey = "your private key";
const FullNode = new HttpProvider("https://vpioneer.infragrid.v.network/");
const SolidityNode = new HttpProvider("https://vpioneer.infragrid.v.network/");
const EventServer = new HttpProvider("https://vpioneer.infragrid.v.network/");

const VisionWeb = new VisionWeb(FullNode, SolidityNode, EventServer, PrivateKey);
const contractObj = require('./BasicToken.json');
const abi = contractObj.abi;
const bytecode = contractObj.bytecode;


// invoke contract
(async function () {
  // contract address
  const contract = await VisionWeb.contract().at("469342bfc79bba12d45e68e9c26dd97076be8ef848");

  let res = await contract.transfer("463a86B966369B5c98F0f7E0B009F4D2aBD4d97162", 100).send({
    feeLimit: 100000000,
    callValue: 0,
    shouldPollResponse: true,
  });
  console.log(res);
})();

Transfer 100VTK

771771