Last active
February 9, 2023 13:43
-
-
Save fipso/683d682fdc41302593cc9ffb0c15eda5 to your computer and use it in GitHub Desktop.
fetch metadata json file from nft by contract address and token id
This file contains 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 { ethers } = require("ethers"); | |
const rpc = ""; | |
const addr = ""; | |
async function main() { | |
// no providers object in ethers v6+ | |
const provider = new ethers.JsonRpcProvider(rpc); | |
const abi = [ | |
"function tokenURI(uint256 tokenId) public view returns (string)", | |
]; | |
const contract = new ethers.Contract(addr, abi, provider); | |
const tokenURI = await contract.tokenURI(1); | |
console.log(tokenURI); | |
} | |
main().then(() => console.log("done")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment