amashukov/eip1559-tx-signer-php

EIP-1559 (Type-2) raw transaction assembly + RFC 6979 deterministic ECDSA signing in pure PHP. Address derivation from a secp256k1 private key.

Maintainers

Package info

github.com/AndreyMashukov/eip1559-tx-signer-php

pkg:composer/amashukov/eip1559-tx-signer-php

Statistics

Installs: 85

Dependents: 1

Suggesters: 1

Stars: 0

Open Issues: 0

v0.1.0 2026-05-24 05:35 UTC

This package is auto-updated.

Last update: 2026-05-24 12:41:12 UTC


README

EIP-1559 (Type-2) Ethereum transaction assembly + RFC 6979 deterministic ECDSA signing in pure PHP.

CI PHPStan L9 Latest Version Downloads PHP License Stars

Assemble and sign EIP-1559 (Type-2) Ethereum transactions in pure PHP. Produces a 0x02-prefixed raw transaction hex ready for eth_sendRawTransaction. Signatures are deterministic per RFC 6979 and canonical low-S, so the same (privateKey, transaction) pair always yields byte-identical output — ideal for reproducible builds, server-side signing, and EVM bridge/withdrawal automation.

Features

  • EIP-1559 / EIP-2718 Type-2 transaction assembly (RLP-encoded, 0x02-prefixed).
  • RFC 6979 deterministic ECDSA signing over secp256k1, canonical low-S.
  • Sender address derivation from the private key.
  • Bigint-safe wei / gas fields via decimal strings (ext-gmp).
  • Empty-key placeholder mode keeps DI containers booting without the real secret.
  • PHPStan level 9 clean, strict_types.

Why amashukov/eip1559-tx-signer-php

The common PHP path to a signed EVM transaction is web3p/ethereum-tx + kornrunner/ethereum-offline-raw-tx, which target the legacy transaction shape and pull in their own crypto stack. This package is focused on the modern Type-2 (EIP-1559) envelope with RFC 6979 deterministic signing as a first-class guarantee, composed from small single-purpose dependencies you can audit independently (keccak / RLP / secp256k1).

Installation

composer require amashukov/eip1559-tx-signer-php

Usage

use Amashukov\Eip1559TxSigner\Eip1559Signer;

$signer = new Eip1559Signer('0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d', chainId: 1);

// Sender address derived from the private key:
echo $signer->address();   // 0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1

$rawTx = $signer->sign(
    to: '0x000000000000000000000000000000000000dEaD',
    valueWei: '0',                            // decimal-string wei (bigint-safe)
    data: '0xf3fef3a3…',                      // calldata, 0x-prefixed
    nonce: 5,
    gasLimit: 100_000,
    maxFeePerGas: '30000000000',              // 30 gwei
    maxPriorityFeePerGas: '1500000000',       // 1.5 gwei
);
// 0x02f8b1…  — broadcast via eth_sendRawTransaction

Empty-key placeholder

Passing an empty private key boots the signer with an all-ones placeholder key. This keeps dependency-injection containers booting in dev/test without the real secret; the resulting transaction is signed by a throwaway key, so any chain that receives it rejects the call — loudly, not silently.

How it works

  1. RLP-encode [chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList] and prepend the 0x02 type byte.
  2. keccak-256 the payload → signing hash.
  3. ECDSA-sign the hash with secp256k1 (RFC 6979 deterministic nonce, canonical low-S).
  4. RLP-encode the same fields plus [yParity, r, s], prepend 0x02 → the signed raw transaction.

Access lists are emitted empty; the signer targets the common "no access list" Type-2 transaction.

Requirements

Related packages

Package Tier Purpose
amashukov/keccak-php leaf keccak-256 hashing
amashukov/rlp-php leaf RLP encoding
amashukov/secp256k1-php leaf ECDSA sign / pubkey derivation
amashukov/abi-encoder-php composite Solidity ABI calldata encoder
amashukov/eth-rpc-client-php RPC Ethereum JSON-RPC client
amashukov/eth-php meta EVM umbrella package

Quality

  • PHPStan level 9.
  • php-cs-fixer with the @PER-CS ruleset.
  • GitHub Actions CI on every push.
  • RFC 6979 deterministic-signature test vectors validate signing output.

License

MIT.