GithubHelp home page GithubHelp logo

evalir / etherscan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dragossutu/etherscan

0.0 1.0 0.0 182 KB

etherscan ctl - a CLI app to interact with etherscan.io API

Rust 84.64% Makefile 0.05% Solidity 15.31%

etherscan's Introduction

Etherscan CLI

etherscan is a CLI app to interact with etherscan.io API or other blockchain explorers built with etherscan.io. Like the ones listed here.

Currently it supports downloading contracts files only and only with verified contracts for which the source code has been upload to the blockchain explorer.

This is project I used to learn Rust, if you have any improvements recommendations or find any bugs please create an issue.

Install

Download

Check the Releases page for latest stable version and update ETHERSCAN_VERSION env var below.

ETHERSCAN_VERSION="1.11.0" \
  && curl -L -o etherscan "https://github.com/dragossutu/etherscan/releases/download/${ETHERSCAN_VERSION}/etherscan-linux-amd64-${ETHERSCAN_VERSION}" \
  && chmod +x etherscan \
  && sudo mv etherscan /usr/local/bin

Build from source

git clone https://github.com/dragossutu/etherscan.git
cd etherscan
cargo build --release

How to use

  1. Create an API key for the block explorer you want to use the CLI for. (requires an account)

  2. Export the API key as an environment variable ETHERSCAN_API_KEY or pass it as a CLI flag:

export ETHERSCAN_API_KEY=your_api_key_here
  1. Download contract files
etherscan 0x34d85c9CDeB23FA97cb08333b511ac86E1C4E258

Unless you used the --files-dest-path flag, the downloaded contracts files will be in a local folder

./contracts/[BLOCKCHAIN NAME]/[CONTRACT ADDRESS]

For the example above the folder would be ./contracts/ethereum/0x34d85c9CDeB23FA97cb08333b511ac86E1C4E258

Usage

$ etherscan --help
A CLI app to interact with etherscan.io API or other blockchain explorers built with etherscan.io

USAGE:
    etherscan [OPTIONS] --api-key <API_KEY> <CONTRACT_ADDRESS>

ARGS:
    <CONTRACT_ADDRESS>
            Address of the contract to download files for

OPTIONS:
    -d, --files-dest-path <FILES_DEST_PATH>
            Local path to the folder where the contract's files will be created

            Folder will be created if it doesn't exist

            [default: ./contracts]

    -h, --help
            Print help information

    -k, --api-key <API_KEY>
            The API key for the block explorer

            It will be read from the environment variable ETHERSCAN_API_KEY first

            [env: ETHERSCAN_API_KEY=]

    -n, --network <NETWORK>
            The name of the network

            Must match the block explorer that the API key is for. e.g if network = arbitrum, the
            CLI will make requests to https://api.arbiscan.io, so the API key must be for
            https://api.arbiscan.io

            [default: ethereum]
            [possible values: arbitrum, aurora, avalanche, bsc, bttc, celo, clv, cronos, ethereum,
            fantom, heco, optimism, moonbeam, moonriver, polygon]

    -u, --api-url <API_URL>
            Used for tests only. The URL of the block explorer's API

            e.g. https://api.etherscan.io. If passed in, the `network` argument is ignored

    -V, --version
            Print version information

Supported blockchains explorers

Contributing

Thanks for your interest in contributing to the etherscan CLI!

If you find a bug or want to add a feature please:

  • check existing issues to verify there isn't another PR for the same bug/feature
  • create an issue
  • create a new branch
  • make sure you have pre-commit installed and configured for this repo
cd etherscan
pre-commit install
  • make your change, add tests and make sure tests pass. The codebase uses semantic-release, so please follow the angular commit message format so that semantic-release can create a new release and update changelog from your commit messages
  • create a pull request

etherscan's People

Contributors

dragossutu avatar semantic-release-bot avatar evalir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.