GithubHelp home page GithubHelp logo

ethereum-depositer's Introduction

Ethereum Deposit Contract Processing Script

Overview

This Node.js script facilitates the processing of Ethereum deposit data. It reads deposit data from a file, interacts with an Ethereum deposit contract, and executes deposit transactions. The script includes features like environment variable-based configuration, transaction locking to prevent double processing, and comprehensive logging.

Features

  • Processes deposit data from a specified file.
  • Connects to Ethereum nodes via JSON-RPC using the ethers.js library.
  • Handles deposit transactions with a given Ethereum deposit contract.
  • Utilizes environment variables for secure configuration.
  • Implements a locking mechanism to prevent duplicate transactions.
  • Logs detailed information about each transaction, including errors.

Requirements

  • Node.js
  • npm (Node Package Manager)
  • An Ethereum node accessible via JSON-RPC
  • A funded Ethereum wallet

Installation

Ensure Node.js and npm are installed on your system. Then, install the required dependencies using npm:

npm install
cp .env-example .env

Configuration

Set up the .env file in the project root, based on .env-example. Configure these variables:

  • PROVIDER_URL: URL of the Ethereum JSON-RPC node.
  • PRIVATE_KEY: Private key of your Ethereum wallet.
  • CONTRACT_ADDRESS: Address of the Ethereum deposit contract.

For transaction configuration, set (optionally):

  • GAS_LIMIT: Maximum gas for transactions.
  • GAS_PRICE: Gas price in Gwei.

Usage

Run the script with a file containing deposit data as an argument:

node sendByFile.js <file_path>

The script will:

  1. Read deposit data from the provided file.
  2. Connect to the Ethereum network.
  3. Process each deposit entry:
    • Check for an existing lock file.
    • Create a transaction with deposit details.
    • Send the transaction to the network.
    • Create a lock file on successful transaction sending.
  4. Log transaction details and errors.

File Format

The script expects a JSON file with an array of deposit data objects. Each object should include:

  • pubkey
  • withdrawal_credentials
  • amount
  • signature

Locking Mechanism

To prevent processing the same deposit data multiple times, the script uses a locking mechanism:

  • Checks for a .lock file associated with each pubkey.
  • Creates a .lock file after successfully processing a transaction.

Disclaimer

This script is for educational and development purposes. Test thoroughly in a safe environment before production use. Secure your private key and sensitive details.

License

MIT

Contributing

Contributions are welcome. Please follow standard coding practices and submit pull requests for enhancements or fixes.

ethereum-depositer's People

Contributors

lyfsn 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.