This Node.js script facilitates the processing of Endurance deposit data. It reads deposit data from a deposit-data.json, interacts with an Endurance deposit contract, and executes deposit transactions. The script includes features like environment variable-based configuration, transaction locking to prevent double processing.
- Processes deposit data from a specified file.
- Connects to Endurance nodes via JSON-RPC using the ethers.js library.
- Handles deposit transactions with a given Endurance deposit contract.
- Utilizes environment variables for secure configuration.
- Implements a locking mechanism to prevent duplicate transactions.
- Node.js
- npm (Node Package Manager)
- An Endurance node accessible via JSON-RPC
- A funded Endurance wallet
Ensure Node.js and npm are installed on your system. Then, install the required dependencies using npm:
git clone https://github.com/OpenFusionist/staking-batch-depositer.git
cd staking-batch-depositer
npm install
cp .env.example .env
Set up the .env file in the project root, based on .env-example. Configure these variables:
PROVIDER_URL: URL of the Endurance JSON-RPC node.PRIVATE_KEY: Private key of your Endurance wallet.CONTRACT_ADDRESS: Address of the Endurance deposit contract.
For transaction configuration, set (optionally):
GAS_LIMIT: Maximum gas for transactions.GAS_PRICE: Gas price in Gwei.
Run the script with a file containing deposit data as an argument:
node batchDeposit.js <file_path>(eg.deposit_data-xxx.json)
The script will:
- Read deposit data from the provided file.
- Connect to the Endurance network.
- 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.
- Log transaction details and errors.
The script expects a JSON file with an array of deposit data objects. Each object should include:
pubkeywithdrawal_credentialsamountsignature
To prevent processing the same deposit data multiple times, the script uses a locking mechanism:
- Checks for a
.lockfile associated with eachpubkey. - Creates a
.lockfile after successfully processing a transaction.
This script is for educational and development purposes. Test thoroughly in a safe environment before production use. Secure your private key and sensitive details.
MIT
Contributions are welcome. Please follow standard coding practices and submit pull requests for enhancements or fixes.
