JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q50072F
  • License MIT

A simple CLI for querying contract information from block-explorers

Package Exports

  • @owodunni/ethscan
  • @owodunni/ethscan/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@owodunni/ethscan) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

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'

Usage

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

Options:
 -h --help            Show this screen.
 -v, --version        Show version.
 -o, --output=<file>  Write to output file
 -d, --debug          Print debug logs

Output contract ABI:

ethscan abi 0xD33526068D116cE69F19A9ee46F0bd304F21A51f
[
{
  "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'
  }
]