A utility for signing Ethereum transactions using different EIP standards (EIP-155, EIP-1559, EIP-2930).
SignTxn is a JavaScript-based tool that allows you to sign Ethereum transactions offline using different transaction types:
- EIP-155: Legacy transactions with replay protection
- EIP-1559: Fee market change transactions (London fork)
- EIP-2930: Optional access lists transactions (Berlin fork)
This tool is useful for developers who need to create and sign transactions for testing, debugging, or interacting with Ethereum networks.
The project is organized into the following directories:
- scripts/: Contains the transaction signing scripts for different EIP standards
sign-eip155-tx.js: Legacy transaction signing (EIP-155)sign-eip1559-tx.js: Fee market transaction signing (EIP-1559)sign-eip2930-tx.js: Access list transaction signing (EIP-2930)
- helpers/: Contains utility functions used by the scripts
utils.js: Common utility functions for parsing method parameters and getting nonce
- abi/: Contains ABI definitions for contract interactions
-
Clone the repository:
git clone https://github.com/yasenltd/SignTxn.git cd SignTxn -
Install dependencies:
npm install -
Configure your environment variables by copying the
.example.envfile to.envand updating the values (see Configuration section below).
The repository contains three scripts for signing different types of transactions:
node scripts/sign-eip155-tx.js
node scripts/sign-eip1559-tx.js
node scripts/sign-eip2930-tx.js
Each script will output the signed transaction as a hexadecimal string that can be submitted to an Ethereum network.
The repository includes a .example.env file with placeholder values. Copy this file to create your own .env file:
cp .example.env .envThen edit the .env file to set your own values for the following variables:
PRIVATE_KEY=your_private_key_here
VALUE=0.001
CHAIN_ID=
GAS_LIMIT=
TARGET_CHAIN_ID=
TO_ADDRESS=0xYourTargetAddressHere
RPC_PROVIDER=https://your-rpc-endpoint.io
# ABI and Method Configuration
USE_METHOD=false
ABI_PATH=./abi/contract.json
METHOD_NAME=deposit
# Optional: Override recipient address (defaults to wallet address if not specified)
# RECIPIENT=0xYourRecipientAddress
# Optional: Override method parameters (JSON array format)
# METHOD_PARAMS=["0xYourRecipientAddress", "0x4268"]
| Variable | Description | Default |
|---|---|---|
PRIVATE_KEY |
Your Ethereum private key (without 0x prefix) | Required |
VALUE |
Amount of ETH to send (in ETH) | 0.0 |
CHAIN_ID |
Chain ID of the network | 1 |
GAS_LIMIT |
Gas limit for the transaction | 21000 |
TARGET_CHAIN_ID |
Target chain ID for cross-chain operations | 0 |
TO_ADDRESS |
Recipient address (contract or EOA) | Required |
RPC_PROVIDER |
RPC endpoint URL | Required |
USE_METHOD |
Whether to create a contract method call | false |
ABI_PATH |
Path to the contract ABI JSON file | ./abi/contract.json |
METHOD_NAME |
Contract method name to call | methodName |
RECIPIENT |
Recipient address for the method call | Wallet address |
METHOD_PARAMS |
JSON array of parameters for the method call | [RECIPIENT, TARGET_CHAIN_ID] |
To sign a simple ETH transfer transaction:
-
Configure your
.envfile:PRIVATE_KEY=your_private_key_here VALUE=0.01 TO_ADDRESS=0xRecipientAddressHere RPC_PROVIDER=https://mainnet.infura.io/v3/your-project-id CHAIN_ID=1 USE_METHOD=false -
Run one of the signing scripts:
node scripts/sign-eip1559-tx.js
To sign a transaction that calls a contract method:
-
Configure your
.envfile:PRIVATE_KEY=your_private_key_here VALUE=0 TO_ADDRESS=0xContractAddressHere RPC_PROVIDER=https://mainnet.infura.io/v3/your-project-id CHAIN_ID=1 USE_METHOD=true METHOD_NAME=transfer METHOD_PARAMS=["0xRecipientAddress", "1000000000000000000"] -
Run one of the signing scripts:
node scripts/sign-eip1559-tx.js
The following curl commands can be used to interact with Ethereum nodes:
curl -X POST https://testnet.rpc.neuraprotocol.io \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["txnSignatureHex"],
"id": 1
}'curl -X POST https://testnet.rpc.neuraprotocol.io \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["address", "pending"],
"id": 1
}'curl -X POST https://testnet.rpc.neuraprotocol.io \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["address", "latest"],
"id": 1
}'| Method | Purpose | Input Required |
|---|---|---|
eth_sendRawTransaction |
Send a signed TX to the chain | Raw signed TX hex |
eth_getTransactionCount |
Get the correct nonce for an account | Address, block tag |
eth_getCode |
Check if address is a contract | Address, block tag (latest) |
- Never commit your
.envfile with your private key to version control (it's already added to.gitignore) - This tool is for development and testing purposes only
- Always verify the transaction details before submitting to a network