Giter VIP home page Giter VIP logo

etherscript's Introduction

📜 Etherscript

A collection of useful scripts for interacting with EVM compatible blockchains from the command line

Environment Variable Management

This repository uses the NPM package @chainlink/env-enc to keep private keys, RPC URLs, and other secrets encrypted at rest. This helps reduce the risk of leaking your private key.

By default, the @chainlink/env-enc package will store your encrypted environment variables in a file named .env.enc in the root directory of this repository. Ensure that your .gitignore file includes.env.enc

Usage

Set the encryption password by running the command

npx env-enc set-pw

Set a new environment variable by running the command

npx env-enc set

See all your currently set environment variables

npx env-enc view

Remove an environment variable

npx env-enc remove SOME_ENV_VAR_NAME

Hardhat Guide

  • hardhat.config.ts specifies the settings like imports, networks, solidity verions, etc that will all be made available through the hre (hardhat runtime environment)

  • all scripts and tasks are by default executed on the local hardhat network, but can be configured to run on other networks by passing the --network flag .i.e. yarn hardhat NAME_OF_TASK --network arbitrum

Scripts

  • good for executing code that doesnt require parameters
yarn hardhat run scripts/PATH_TO_SCRIPT.ts

Tasks

  • good for executing scripts that require parameters passed on the command line
  • to see all availalble tasks run yarn hardhat
  • to see which flags you need to pass run yarn hardhat NAME_OF_TASK --help
  • not allowed to import hre into scripts that are imported and used by tasks
yarn hardhat NAME_OF_TASK --NAME_OF_FLAG VALUE_OF_FLAG

Script Glossary

swap

Swap tokens using uniswap's smart order router that computes the optimal route before executing the swap.

Required flags
Parameter Description
amount The human readable amount of the token to swap in
in The symbol of the token to swap in
out The symbol of the token to swap out
Example usage

Execute a swap on the local hardhat network that is configured as fork of arbitrum

yarn hardhat swap --in USDC --amount 100 --out rETH

get-abi

Fetches abi from etherscan API and outputs the result to a .json file inside the ./abis directory

Required flags
Parameter Description
contract The target contract address (must be verified on etherscan)
file-name The name for the file that will be output into abis directory
Example usage
yarn hardhat get-abi --contract 0x514910771AF9Ca656af840dff83E8264EcF986CA --file-name link-token-abi --network mainnet

get-price

Gets the price for a base asset in terms of a quote asset using chainlink price feeds

Required flags
Parameter Description
contract The chainlink price feed contract address
Example usage

Fetch the price of ETH in USD on mainnet

yarn hardhat get-price --contract 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 --network mainnet

etherscript's People

Contributors

mattpereira avatar

Stargazers

 avatar Tantō Defi avatar

Watchers

 avatar

Forkers

mohamadhammoud

etherscript's Issues

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.