Skip to content

Instantly share code, notes, and snippets.

@geggleto

geggleto/app.js Secret

Created September 18, 2021 04:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geggleto/da5a89b6941d2c318587cc646149d365 to your computer and use it in GitHub Desktop.
Save geggleto/da5a89b6941d2c318587cc646149d365 to your computer and use it in GitHub Desktop.
//Item Contract: '0x6558F6462Fdc83048b029AcEB485E85990Dfc514'
//Card Contract: '0x339b4e30B8A32b2473E48Aa6560298b1Fd28bb39'
const Web3 = require("web3");
let web3 = new Web3(new Web3.providers.HttpProvider("https://polygon-rpc.com"));
(async (web3) => {
let blockNumber = await web3.eth.getBlockNumber();
let origin = 18858793;
let target = origin + 5000;
do {
console.log(`Starting Loop with values ${origin} and ${target} max ${blockNumber}`);
let logs = await web3.eth.getPastLogs({
fromBlock: origin, // block origin
toBlock: target,
address: "0x6558f6462fdc83048b029aceb485e85990dfc514",
topics: ['0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62']
})
for (let entry of logs) {
let data = web3.eth.abi.decodeParameters([{
type: 'uint256',
name: 'TokenId'
}, {
type: 'uint256',
name: 'count'
}], entry.data);
// console.log("Transfer", entry.topics[2], entry.topics[3], data.TokenId, data.count);
console.log("Removal", entry.topics[2], data.TokenId, -1 * data.count);
console.log("Addition", entry.topics[3], data.TokenId, data.count);
}
origin += 5001;
target = origin+5000;
} while(target<blockNumber);
})(web3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment