npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2024 โ€“ย Pkg Stats / Ryan Hefner

constructor-argument-detector

v1.1.5

Published

๐Ÿš€ Terminal util to find constructor arguments when creating a contract in ethereum based networks

Downloads

18

Readme

constructor-argument-detector

๐Ÿš€ Terminal util to find constructor arguments when creating a contract in ethereum based networks

npm (tag)

Get Started

npm install -g constructor-argument-detector

Usage

Usage: constructor-detector [options] <transaction-hash-of-creation-contract>

CLI to find constructor argument in ethereum based chain contracts

Arguments:
  hash                  Tx of creating transactions

Options:
  -e, --endpoint <url>  RPC endpoint url
  -t, --types <string>  Constructor types (Example: uint,string,address)
  -h, --help            display help for command

Example

user@macbook ~ % constructor  -e https://bsc-dataseed1.binance.org \
                              -t address,address \
                              0x1bfbff8411ed44e609d911476b0d35a28284545b690902806ea0a7ff0453e931

(address) 0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73
(address) 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

Or set RRC endpoint to env

user@macbook ~ % export WEB3_ENDPOINT=https://bsc-dataseed1.binance.org
user@macbook ~ % constructor -t address,address,address,address,address,uint 0xc0e636dcebeeed30525f1ca2214b93331fe2263adc87cd467d57d4ff04257d4d
(address) 0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82
(address) 0xa5f8C5Dbd5F286960b9d90548680aE5ebFf07652
(address) 0x7a2C5c265bDC9724dACe715c5FF60Eea40E07F47
(address) 0xeCc90d54B10ADd1ab746ABE7E83abe178B72aa9E
(address) 0xeCc90d54B10ADd1ab746ABE7E83abe178B72aa9E
(uint) 0

Or using as library

const detector = require("constructor-argument-detector");

detector.parse({
    txHash: "0xc0e636dcebeeed30525f1ca2214b93331fe2263adc87cd467d57d4ff04257d4d",
    endpoint: "https://bsc-dataseed1.binance.org/",
    types: ["address", "address", "address", "address", "address", "uint"]
}).then(result => {
    console.log(result);
})

/* Output:
[
  {
    type: 'address',
    value: '0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82'
  },
  {
    type: 'address',
    value: '0xa5f8C5Dbd5F286960b9d90548680aE5ebFf07652'
  },
  {
    type: 'address',
    value: '0x7a2C5c265bDC9724dACe715c5FF60Eea40E07F47'
  },
  {
    type: 'address',
    value: '0xeCc90d54B10ADd1ab746ABE7E83abe178B72aa9E'
  },
  {
    type: 'address',
    value: '0xeCc90d54B10ADd1ab746ABE7E83abe178B72aa9E'
  },
  {
    type: 'uint',
    value: BigNumber { _hex: '0x00', _isBigNumber: true }
  }
]
*/

To resolve the issue, we need data from tx.input and the actual smart contract code. You can extract this data yourself

const detector = require('constructor-argument-detector');
const ethers = require('ethers');
const provider = new ethers.providers.JsonRpcProvider("https://bsc-dataseed1.binance.org/");

provider.getTransaction('0xc0e636dcebeeed30525f1ca2214b93331fe2263adc87cd467d57d4ff04257d4d').then(async (tx) => {
    const data = tx.data;
    const addressOfContract = '0x45c54210128a065de780C4B0Df3d16664f7f859e';
    const byteCode = await provider.getCode(addressOfContract);
    
    const result = detector.offchainParse({
        txData: data,
        byteCode,
        types: ["address", "address", "address", "address", "address", "uint"]
    })
    console.log(result);
})