Last active
September 15, 2021 11:27
-
-
Save zquestz/fad9ccf9ffe9be5425583100778754b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const TOKEN_CONTRACT_ADDRESS="0xc70c7718C7f1CCd906534C2c4a76914173EC2c44" | |
const YOUR_ETH_ADDRESS="0x6cdde7dd0acc56cabfc2315791016f7c334d72c3" | |
// The minimum ABI to get SEP20 Token balance | |
const minABI = [ | |
{ | |
constant: true, | |
inputs: [{ name: "_owner", type: "address" }], | |
name: "balanceOf", | |
outputs: [{ name: "balance", type: "uint256" }], | |
type: "function", | |
}, | |
{ | |
constant: true, | |
inputs: [], | |
name: "decimals", | |
outputs: [{ name: "", type: "uint8" }], | |
type: "function", | |
}, | |
]; | |
// Get SEP20 Token contract instance | |
const contract = new web3js.eth.Contract(minABI, TOKEN_CONTRACT_ADDRESS) | |
// Call balanceOf function | |
const result = await contract.methods.balanceOf(YOUR_ETH_ADDRESS).call(); | |
const format = Web3NoMeta.utils.fromWei(result); | |
console.log(format); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment