deployless-view
v1.1.1
Published
* package name: deployless-view * build: `yarn build`
Downloads
171
Readme
deployless-view
- package name: deployless-view
- build:
yarn build
Install
npm i deployless-view
Usage
batchGetAllTokensByOwner
Specific use case for multicall.
The method batchGetAllTokensByOwner is just a wrapper for method multicall which calls DeploylessNFTViewer with easy interface.
nftType
1: ERC721Enumerable
2: CryptoPunks
3: ERC721 without ERC721Enumerable(rare case)
const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");
const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"
async function main () {
const provider = new ethers.providers.JsonRpcProvider(rpc);
let d = new DeploylessViewerClient(provider)
let ret = await d.batchGetAllTokensByOwner('0x7a9fe22691c811ea339d9b73150e6911a5343dca', [
{
nftType: 2,
nft: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb'
}, {
nftType: 1,
nft: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d'
}])
console.log(`ret:`, ret)
}
main()
getTokensByOwnerInRange
Get the id owned by the user in the specified token id range.
const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");
const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"
async function main () {
const provider = new ethers.providers.JsonRpcProvider(rpc);
let d = new DeploylessViewerClient(provider)
let ret = await d.getTokensByOwnerInRange(
'0x7a9fe22691c811ea339d9b73150e6911a5343dca', // owner
"0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb", // nft address
2, // nftType
1000, // start id
2000 // count or step (excluded)
)
console.log(`ret:`, ret)
}
main()
getAllTokensByOwner
const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");
const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"
async function main () {
const provider = new ethers.providers.JsonRpcProvider(rpc);
let d = new DeploylessViewerClient(provider)
let ret = await d.getAllTokensByOwner(
'0x7a9fe22691c811ea339d9b73150e6911a5343dca', // owner
"0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb", // nft address
2, // nftType
2000 // step
)
console.log(`ret:`, ret)
}
main()
getUserTimeLocks
const { DeploylessViewerClient } = require('deployless-view')
const { ethers } = require("ethers");
const rpc = "https://mainnet.infura.io/v3/<YOUR_API_KEY>"
async function main () {
const provider = new ethers.providers.JsonRpcProvider(rpc);
let d = new DeploylessViewerClient(provider)
let ret = await d.getUserTimeLocks(
'timelock address', // timelock contract address
"user address", // user address
50, // The maximum number of requests in a single request. default and max:50
2000 // The minimum timelock agreement start id
)
console.log(`ret:`, ret)
}
main()
multicall
Accept an array of calls and call them all at once.
If 0x0 is passed as address to call, DeploylessNFTViewer will be called instead.
const {
DeploylessViewerClient,
NFTEnumerable__factory,
} = require('deployless-view')
const { ethers } = require('ethers')
const rpc = 'https://mainnet.infura.io/v3/af88d7776e3f4e1888ac935b9b16effd'
async function main () {
const provider = new ethers.providers.JsonRpcProvider(rpc)
let d = new DeploylessViewerClient(provider)
let ret = await d.multicall([
{
target: ethers.constants.AddressZero,
callData: d.deploylessNFTViewer.interface.encodeFunctionData('batchGetAllTokensByOwner', [
'0x7a9fe22691c811ea339d9b73150e6911a5343dca', [
{
nftType: 2,
nft: '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb',
}, {
nftType: 1,
nft: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
}]]),
},
{
target: '0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d',
callData: NFTEnumerable__factory.createInterface()
.encodeFunctionData('tokenURI', [999]),
},
])
let { blockNumber, resultsArray: [ret1, ret2] } = ret
let ret1Value = d.deploylessNFTViewer.interface.decodeFunctionResult('batchGetAllTokensByOwner', ret1)
let ret2Value = NFTEnumerable__factory.createInterface()
.decodeFunctionResult('tokenURI', ret2)
console.log(`ret1Value:`, ret1Value)
console.log(`ret2Value:`, ret2Value)
}
main()