buildSignAndEncodeRaw method
Builds, signs, and encodes a complete EIP-7702 transaction into a
raw hex string suitable for submission via eth_sendRawTransaction.
This helper performs the full transaction pipeline:
- Constructs an Unsigned7702Tx using buildUnsigned.
- Signs the transaction using signUnsigned and the provided Signer.
- Serializes the signed transaction via parseRawTransaction.
The resulting hex string contains the typed transaction prefix (0x04)
followed by the RLP-encoded body and is ready for broadcast to any
JSON-RPC node.
Parameters:
signer— the signer producing the ECDSA signature.to— the destination address of the transaction.value— optional ether value to transfer.data— optional calldata payload.authorizationList— one or more previously constructed AuthorizationTuple values to include in the EIP-7702authorizationListfield.
Example:
final raw = await builder.buildSignAndEncodeRaw(
signer: signer,
to: recipient,
data: myCallData,
);
await client.sendRawTransaction(raw);
Implementation
Future<HexString> buildSignAndEncodeRaw({
required Signer signer,
required HexString to,
BigInt? value,
Uint8List? data,
List<AuthorizationTuple> authorizationList = const [],
}) async {
final unsignedTx = await buildUnsigned(
sender: signer.ethPrivateKey.address.eip55With0x,
to: to,
value: value,
data: data,
authorizationList: authorizationList,
);
final signedTx = await signUnsigned(signer: signer, unsignedTx: unsignedTx);
final rawTx = parseRawTransaction(signedTx, chainId: ctx.chainId?.toInt());
return rawTx;
}