Hey Gm folks -
I am n00b in smart contracts so learning as I go - using Nethereum & Infura
I want to query a smart contract on mainnet to get totalsupply
A colleague sent an example using ethers… just trying to move it over - which channel is best to ask?
Example (without contract address and my infuracode) is:
const network = “mainnet”;
const provider = new ethers.providers.InfuraProvider(network, { infura: ‘INFURACODE’ });
const contractAddress = “SMARTCONTRACTADDRESS”;
const contractABI = [{“inputs”: [], “name”: “totalSupply”, “outputs”: [ { “internalType”: “uint256”, “name”: “”, “type”: “uint256” } ],“stateMutability”: “view”,“type”: “function” }];
const contract = new ethers.Contract(contractAddress, contractABI, provider);
async function getSupply(result) {
var supply = await contract.totalSupply();
document.write(’{“supply”:"’+supply+’"}’);
}
getSupply();