Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

check token balance of an address using web3

const minABI = [
  {
    constant: true,

    inputs: [{ name: "_owner", type: "address" }],

    name: "balanceOf",

    outputs: [{ name: "balance", type: "uint256" }],

    type: "function",
  },
];

const web3client = new Web3(new Web3.providers.HttpProvider(provider));

const getBalance = async (client, contractAddress, walletAddress) => {
  const contract = new client.eth.Contract(minABI, contractAddress);
  const result = await contract.methods.balanceOf(walletAddress).call();
  const format = client.utils.fromWei(result);
};
 
PREVIOUS NEXT
Tagged: #check #token #balance #address
ADD COMMENT
Topic
Name
7+7 =