Skip to content

Instantly share code, notes, and snippets.

@mehranhydary
Created September 3, 2021 11:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mehranhydary/24bd78a6bcb75117eab3ec8a861f705e to your computer and use it in GitHub Desktop.
Save mehranhydary/24bd78a6bcb75117eab3ec8a861f705e to your computer and use it in GitHub Desktop.
check-settlement.js
/*
1. Run `npm init` in a new folder
2. Install ethers.js with `npm i ethers`
3. Create a file called `check-settlement.js`
4. Copy the script below and save it in the file you create
5. In your terminal, run `node check-settlement.js`
*/
require("dotenv").config();
const ethers = require("ethers");
const axios = require('axios').default;
const provider = new ethers.providers.JsonRpcProvider(`https://eth-mainnet.alchemyapi.io/v2/${process.env.NEXT_PUBLIC_ALCHEMY_API_KEY}`);
const settlements = new ethers.Contract(
"0xdEcC60000ba66700a009b8F9F7D82676B5cfA88A",
// need the contract abi
provider
);
let wallet;
let nonce;
async function checkSettlementOwner(tokenId) {
const settlementsConnected = settlements.connect(wallet);
let result = await settlementsConnected.ownerOf(tokenId);
console.log(result);
}
(async () => {
wallet = ethers.Wallet.createRandom().connect(provider);
nonce = await provider.getTransactionCount(wallet.address);
for(let i = 1; i < 9901; i++) { // max is 7777; set to 7778
try {
await checkSettlementOwner(ethers.utils.hexlify(i));
} catch (error) {
console.error(error);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment