I've been trying to figure out how to check the balance of Alpaca tokens in my MetaMask wallet. After doing some research, I came across a code snippet that I tried to use but it ended up throwing an error:
TypeError: contract.balanceOf is not a function
This is the code snippet I found:
let minABI = [
// balanceOf
{
"constant":true,
"inputs":[{"name":"_owner","type":"address"}],
"name":"balanceOf",
"outputs":[{"name":"balance","type":"uint256"}],
"type":"function"
},
];
let alpacaAddress = "0x8F0528cE5eF7B51152A59745bEfDD91D97091d2F";
let contract = new web3.eth.Contract(minABI, alpacaAddress);
contract.balanceOf(MyWallet, (error, balance) => {
console.log(balance.toString());
});
Has anyone encountered this issue before with contract.balanceOf not being recognized as a function?