Skip to content

Instantly share code, notes, and snippets.

@itinance
Created January 27, 2022 17:37
Show Gist options
  • Save itinance/e624fd41d6a184f0f9c66ba456c50208 to your computer and use it in GitHub Desktop.
Save itinance/e624fd41d6a184f0f9c66ba456c50208 to your computer and use it in GitHub Desktop.
Execute tokenURI-method on ERC721-contract
const ethers = require('ethers');
const API_KEY = 'YOUR_INFURA_APIKEY';
// The Contract interface
const abi = [
"function tokenURI(uint256 _tokenId) external view returns (string)",
];
// the contract interface
const contractAddress = "0x2f3ee0ace02c71bc82863a28633c0f983a5435bb";
const network = 'rinkeby';
const infuraProvider = new ethers.providers.InfuraProvider(network, API_KEY);
// We connect to the Contract using a Provider, so we will only
// have read-only access to the Contract
let contract = new ethers.Contract(contractAddress, abi, infuraProvider);
let currentValue = contract.tokenURI(1);
currentValue.then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment