Skip to content

Three scripts to ordinary generate, EIP-4844-type generate, and execute a signed raw transaction with `ethers`.

License

Notifications You must be signed in to change notification settings

pcaversaccio/raw-tx

Repository files navigation

Ethereum Raw Transaction Signing Script

👮‍♂️ Sanity checks License: WTFPL

Three scripts to ordinary generate, EIP-4844-type generate, and execute a signed raw transaction with ethers.

Installation

It is recommended to install pnpm through the npm package manager, which comes bundled with Node.js when you install it on your system. It is recommended to use a Node.js version >= 20.0.0.

Once you have npm installed, you can run the following both to install and upgrade pnpm:

npm install -g pnpm

After having installed pnpm, simply run:

pnpm install

.env File

Create a .env file in the root directory and place the private key of your wallet used for signing in the variable PRIVATE_KEY and the RPC provider for the transaction in the variable RPC_PROVIDER. Example:

PRIVATE_KEY=abc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
RPC_PROVIDER=https://rpc.ankr.com/eth_goerli

Generate a Signed Raw Transaction

Configure the placeholder(s) payload in sign or sign-eip4844 according to your needs and run:

pnpm generate

or

generate:eip4844

This will print all raw transaction details to your terminal. Use the output signedTx.serialized to broadcast a transaction e.g. with services like pushTx. You can also use the automatically saved serialised signed transaction in signed_serialised_transaction.json (in the scripts/out directory) via pnpm execute as explained in the next section.

Execute a Signed Raw Transaction

Configure your RPC provider in execute according to your needs and run:

pnpm execute

If the transaction is successful, it saves a file transaction_receipt.json or in case of a failure a file transaction_error.json in the scripts/out directory.

About

Three scripts to ordinary generate, EIP-4844-type generate, and execute a signed raw transaction with `ethers`.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published