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.
- 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.
$ git clone https://github.com/silence-laboratories/TxElizaExample
$ cd TxElizaExample
$ npm install
$ chmod +x cli.js
$ npm link
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
$ 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
.
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.
$ 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.
- 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.