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

@owodunni/ethscan

v0.3.1

Published

A simple CLI for querying contract information from block-explorers

Downloads

4

Readme

Ethscan

CodeFactorBuildnpm versionLicensecodecov

A simple CLI for querying contract information from block-explorers.

Install

npm install -g @owodunni/ethscan

Configure

By default Ethscan querries Etherscans api, this is rate limited to 1Hz. To change Blockexplorer or use an API key the following environment variables can be set:

ETHSCAN_KEY='Your api key'
ETHSCAN_URL='https://rinkeby.etherscan.io/api'

These can also be set by the cli. There are predefined block-explorers for Polygon, Ethereum, Fantom, BSC.

Usage

ethscan -h
Usage:
  ethscan (abi | code) <address> [options]
  ethscan -h | --help | --version

Options:
  -o, --output=<file>    Write to output file.
  -k, --api=<key>        API key
  -u, --url=<url>        Block-explorer url
  -c, --chain=<name>     Use predefined chain block-explorer
  -h --help              Show this screen.
  -v, --version          Show version.
  -d, --debug            Print debug logs.

Output contract ABI:

ethscan abi 0xD33526068D116cE69F19A9ee46F0bd304F21A51f -chain ethereum
[
{
  "inputs": [
    {
      "internalType": "contract RocketStorageInterface",
      "name": "_rocketStorageAddress",
      "type": "address"
    },
    {
      "internalType": "contract IERC20",
      "name": "_rocketTokenRPLFixedSupplyAddress",
      "type": "address"
    }
  ],
  "stateMutability": "nonpayable",
  "type": "constructor"
},
...
]

Save contract code:

ethscan code 0xD33526068D116cE69F19A9ee46F0bd304F21A51f -o ~/code
    ~/code  tree .
.
├── contracts
│   ├── contract
│   │   ├── RocketBase.sol
│   │   └── token
│   │       └── RocketTokenRPL.sol
│   └── interface
│       ├── dao
│       │   └── protocol
│       │       └── settings
│       │           └── RocketDAOProtocolSettingsInflationInterface.sol
│       ├── RocketStorageInterface.sol
│       ├── RocketVaultInterface.sol
│       └── token
│           └── RocketTokenRPLInterface.sol
└── @openzeppelin
    └── contracts
        ├── math
        │   └── SafeMath.sol
        ├── token
        │   └── ERC20
        │       ├── ERC20Burnable.sol
        │       ├── ERC20.sol
        │       └── IERC20.sol
        └── utils
            └── Context.sol

14 directories, 11 files

Output contract code:

ethscan code 0xD33526068D116cE69F19A9ee46F0bd304F21A51f
[
...
{
    content: '/**\n' +
      '  *       .\n' +
      '  *      / \\\n' +
      "  *     |.'.|\n" +
      "  *     |'.'|\n" +
      "  *   ,'|   |`.\n" +
      "  *  |,-'-|-'-.|\n" +
      '  *   __|_| |         _        _      _____           _\n' +
      '  *  | ___ \\|        | |      | |    | ___ \\         | |\n' +
      '  *  | |_/ /|__   ___| | _____| |_   | |_/ /__   ___ | |\n' +
      '  *  |    // _ \\ / __| |/ / _ \\ __|  |  __/ _ \\ / _ \\| |\n' +
      '  *  | |\\ \\ (_) | (__|   <  __/ |_   | | | (_) | (_) | |\n' +
      '  *  \\_| \\_\\___/ \\___|_|\\_\\___|\\__|  \\_|  \\___/ \\___/|_|\n' +
      '  * +---------------------------------------------------+\n' +
      '  * |    DECENTRALISED STAKING PROTOCOL FOR ETHEREUM    |\n' +
      '  * +---------------------------------------------------+\n' +
  ...
      'interface RocketTokenRPLInterface is IERC20 {\n' +
      '    function getInflationCalcTime() external view returns(uint256);\n' +
      '    function getInflationIntervalTime() external view returns(uint256);\n' +
  ...
      '}\n',
    path: '/contracts/interface/token/RocketTokenRPLInterface.sol'
  }
]

Development

For local development linking the package is useful. This enables us to use a development version of ethscan instead of fetching from npm.

npm link

Contribution

Contributions are welcome! Leave an issue or send an email.

Don't forget to format the code:

npm run fix