This demo retrieves the owner of an NFT by Token ID programmatically using the ERC-721 ABI.
We call the ownerOf
method, but any of the methods are available here:
I use Node v11.14.0 (earlier may also work) managed by nvm
Clone this repo locally
git clone https://github.com/cryptogoth/demo-erc721.git
Install dependencies with yarn
or npm install
yarn
Create a secure, web-accessible Ethereum account by going to http://ethgarden.com
and copying and pasting them into your .env
file.
This wallet doesn't need any ETH so far and isn't used to hold any assets. You'll fund it later and use it if you need to call contract mutator methods that change on-chain state.
For this demo, we only call read-only methods.
Edit these lines in the .env
file
MAINNET.DEPLOYER_ADDRESS=''
MAINNET.DEPLOYER_PASSWORD=''
Do the thing
yarn depart
Wait a few seconds, and you'll see some output (the owner of an ERC721 NFT on mainnet)
NFT Owner is {"0":"0x66040374e443ae3e25afef08a781c4c2d175f43c"}
You can verify this with the NFT on Etherscan:
Rejoice! Please send questions or feedback to us on Twitter @cryptogoth