amashukov/eip1559-tx-signer-php
EIP-1559 (Type-2) Ethereum transaction assembly + RFC 6979 deterministic ECDSA signing in pure PHP.
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.
0x02-prefixed).ext-gmp).strict_types.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).
composer require amashukov/eip1559-tx-signer-php
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
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.
Eip1559Signer implements Eip1559SignerInterface (address() + sign()). Type-hint the interface in your services and the container wires the concrete signer in production; in tests, swap a deterministic, key-free double for the interface so signing output never depends on a real private key.
use Amashukov\Eip1559TxSigner\Eip1559SignerInterface;
public function __construct(private Eip1559SignerInterface $signer) {}
[chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList] and prepend the 0x02 type byte.[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.
ext-gmp| 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 |
@PER-CS ruleset.MIT.
How can I help you explore Laravel packages today?