Created
August 7, 2021 16:49
-
-
Save Brunya/dd84207d11ed941c83ba9f73018f4ed2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require("dotenv").config(); | |
const ethers = require("ethers"); | |
const { aggregate } = require("@makerdao/multicall"); | |
const provider = new ethers.providers.JsonRpcProvider( | |
env.PROVIDER | |
); | |
async function contractTest() { | |
const mutagenTokenAbi = require("./static/abis/mutagenToken.json"); | |
const mutagenAddress = "0xDf9E0684F15e60cFCC646ACffB02d97D2D5a1a67"; | |
const testHolder = "0x8501186c56fe4d6deb80a600be7a2a6c6138b972" | |
const mutagenToken = new ethers.Contract( | |
mutagenAddress, | |
mutagenTokenAbi, | |
provider | |
); | |
const quantity = await mutagenToken.balanceOf(testHolder); | |
const requests = [] | |
for (var i = 0; i < quantity; i++) { | |
requests.push({ | |
target: mutagenAddress, | |
call: ['tokenOfOwnerByIndex(address,uint256)(uint256)', | |
testHolder,i], | |
returns: [[i, val => val & 3]] | |
}) | |
} | |
const config = { | |
rpcUrl: env.PROVIDER, | |
multicallAddress: '0x5ba1e12693dc8f9c48aad8770482f4739beed696' | |
}; | |
const {results: {transformed}} = await aggregate(requests, config) | |
const types = Object.values(transformed) | |
console.log({ | |
Genesis: types.includes(0), | |
Print: types.includes(1), | |
Mutagen: types.includes(2), | |
}); | |
} | |
contractTest(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment