Skip to content

Instantly share code, notes, and snippets.

@fukaoi
Created April 20, 2021 04:10
Show Gist options
  • Save fukaoi/1013cbdd164dcd3343e2df3d9bbcc9ee to your computer and use it in GitHub Desktop.
Save fukaoi/1013cbdd164dcd3343e2df3d9bbcc9ee to your computer and use it in GitHub Desktop.
fetch token url from smart contract at NFT toreka (NTX)
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.infura.io/v3/1835809e0e6a4de38eaf1f7afb51e0ec');
const contractAddress = '0x34047D5d7F4C906998e0d9Def0d2Dc3B523d8398';
const abi = [
{
"constant": true,
"inputs": [
{
"name": "_tokenId",
"type": "uint256"
}
],
"name": "tokenURI",
"outputs": [
{
"name": "",
"type": "string"
}
],
"payable": false,
"stateMutability": "view",
"type": "function",
},
];
const tokenId = 3767;
new web3.eth.Contract(abi, contractAddress).methods.tokenURI(tokenId).call().then(res => {
console.log(res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment