toEnvelope method

Envelope toEnvelope()

Implementation

Envelope toEnvelope() {
  final calldata = encodeCalldata();
  final isEip1559 = maxFeePerGas != null || maxPriorityFeePerGas != null;

  return Envelope(
    kind: isEip1559 ? EnvelopeKind.eip1559 : EnvelopeKind.legacy,
    to: contract.address.bytes,
    value: value ?? BigInt.zero,
    data: calldata,
    gasLimit: gasLimit,
    nonce: nonce,
    chainId: chainId,
    gasPrice: gasPrice,
    maxFeePerGas: maxFeePerGas,
    maxPriorityFeePerGas: maxPriorityFeePerGas,
  );
}