Skip to content

silence-laboratories/TxElizaExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TxElizaExample

Ethereum Transaction CLI Tool

TxElizaExample is a command-line tool that allows users to create and broadcast Ethereum transactions. It supports generating unsigned transactions, signing them externally, and broadcasting them to the Ethereum network.

Flow to use the tool

  • Generate an unsigned Ethereum transaction and save it to a file.
  • Sign the transaction externally (e.g., using a hardware wallet or other tools or in this case, using the ElizaOS agent).
  • Broadcast the signed transaction to the Ethereum network.
  • Supports Infura as an Ethereum provider.

Installation

Clone the repository and install dependencies:

$ git clone https://github.com/silence-laboratories/TxElizaExample
$ cd TxElizaExample
$ npm install
$ chmod +x cli.js
$ npm link

Configuration

Create a .env file in the root directory and configure the following environment variables:

INFURA_API_KEY=your_infura_api_key
NETWORK=sepolia  # or any other Ethereum network

Usage

1. Create an Unsigned Transaction

$ eth-tx create-unsigned -s <sender_address> -r <receiver_address> -v <amount_in_eth>

Example:

$ eth-tx create-unsigned -s 0xYourSenderAddress -r 0xReceiverAddress -v 0.1

This command will generate an unsigned transaction and save it to unsignedTx.json.

2. Sign the Transaction Externally

Use an external wallet or signing tool to sign the transaction using the private key of the sender. The signed output should be a 130-character hexadecimal string (R + S) and a recovery ID.

3. Broadcast the Signed Transaction

$ eth-tx broadcast -s <signed_hex> -r <recovery_id>

Example:

$ eth-tx broadcast -s aabbccddeeff... -r 1

This will submit the signed transaction to the Ethereum network.

Notes

  • Ensure that the Infura API key is set in the .env file.
  • The transaction will be stored in unsignedTx.json until it is broadcasted.
  • After successful broadcasting, the unsignedTx.json file is deleted automatically.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published