Socket
Book a DemoInstallSign in
Socket

deployless-viewer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deployless-viewer

```shell npm i deployless-viewer ```

latest
npmnpm
Version
1.0.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Install

npm i deployless-viewer

Usage

batchGetAllTokensByOwner

Specific use case for multicall.

The method batchGetAllTokensByOwner is just a wrapper for method multicall which calls DeploylessNFTViewer with easy interface.

const { DeploylessViewerClient } = require('deployless-viewer')
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()
  • nftType

1: ERC721Enumerable

2: CryptoPunks

3: ERC721 without ERC721Enumerable(rare case)

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-viewer')
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()

FAQs

Package last updated on 14 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.