Skip to content

jaseem-ktk/abi-parser

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract Parser / ABI Parser

Introduction

The following project is to make it simple to build table defenitions for ETL on multiple chains.

Currently it supports:

  • Ethereum
  • Polygon
  • Binance Smart Chain

Architecture

The project is broken into two-parts

Frontend

This is a simple react app.

  1. Lets user input addresses or ABI.
  2. This is then sent to the backend to get the table defentions.
  3. Once table defenitions are fetched, they are displayed allowing you to rename the dataset name and contract name.
  4. Once the names have been set, you can simply download the created table defenitions for events or function calls.

Backend

This is a simple python flask app.

Has multiple endpoints that returns either abi or table defenitions.

Currently it works by connecting to Etherscan based explorer api's to grab the ABI from contract address.

It currently supports grabbing data from etherscan, polygonscan and bscscan

Testing Locally while developing

Move into the contract-parser-api directory

  1. Install backend dependencies using pipenv, poetry or any of your chooses python virutal environments, by running pip install -r requirements.txt

  2. Copy .env.example to .env and set-up env vars

  3. Simply run python3 app.py

  4. Move to the frontend directory

  5. ``yarn install`

  6. yarn start

  7. If everything worked as expected you should have a working local version of contract-parser fronted deployed that will use the api that you just started

To run tests:

  1. Install dev dependencies:
    $ pip install -r requirements-dev.txt
  2. Run tests:
    $ pytest

Hosting

Read below to understand how the project is deployed

Frontend

This is hosted on firebase. Currently there are two version of this.

Version Firebase Project Name URL
Development nansen-contract-parser-dev https://nansen-contract-parser-dev.web.app/
Production nansen-contract-parser-prod https://nansen-contract-parser-prod.web.app/

There are two important files that tell firebase how to host this, .firebaserc and firebase.json

the build commands are specified in package.json

It is important for you to have firebase-tools installed. You can install this by running

npm install -g firebase-tools

Once installed you will need to login to firebase, this can be done using the command below

firebase login

Once logged in you should be able to deploy the frontend

Deployment

To deploy to dev:

firebase use dev
yarn build:dev
yarn deploy:dev

To deploy to prod:

firebase use prod
yarn build:prod
yarn deploy:prod

### Backend

This is currenty run on cloud-run under the following proejcts

Version GCP Project Name URL
Development nansen-contract-parser-dev https://contract-parser-api-s27o6wzppa-uc.a.run.app/api/
Production nansen-contract-parser-prod https://contract-parser-api-7s4aptchzq-uc.a.run.app/api/

There are a few important files that tell cloudrun how to run this properlly. Dockerfile tells google how to run the containerized version of the project. iam.sh is a helper script to create the necessary service workers and set the correct roles. deploy.sh is used to deploy the project in production and development environments.

It is important that you have installed and intialized gcloud sdk

You can run the following command to login with your nansen email

gcloud auth login

Deployment

  1. If this is the first time deploying run bash iam.sh dev, or bash iam.sh prod
  2. Next you can run bash deploy.sh dev or bash deploy.sh prod to deploy the backend to dev or prod set-up

Deploying Everything at Once

To make things simple you can run the following script deployAll.sh

dev: bash deployAll.sh dev prod: bash deployAll.sh prod

Adding Support for More Chains

  1. Identify the etherscan built explorer for this chain. (ie: polygonscan, bscscan, ftmscan, ..)
  2. Create an account and make an API Key
  3. Note down the api URL
  4. Follow the steps in this PR
  5. Done, you have now added a new chain to contract-parser!

About

Web app which parses smart contracts and outputs queries and tables for Ethereum-ETL

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 57.8%
  • Python 31.6%
  • Shell 7.5%
  • HTML 1.8%
  • Dockerfile 1.3%