RawEVMTransactionType0.fromHex constructor
RawEVMTransactionType0.fromHex( - String messageHex
)
Implementation
factory RawEVMTransactionType0.fromHex(String messageHex) {
final rawTxHex = messageHex.replaceFirst("0x", "");
final rlpDecoded = decodeRLP(rawTxHex.hexToBytes, 0).result;
if (rlpDecoded is! List) {
throw Exception("Error RLP decoding transaction: $rlpDecoded");
}
final decodedList = rlpDecoded.whereType<String>().toList();
if (decodedList.length < 9) {
throw Exception("Invalid transaction, missing fields: $decodedList");
}
final nonce = parseAsHexBigInt(decodedList[0]);
final gasPrice = parseAsHexBigInt(decodedList[1]);
final gasLimit = parseAsHexBigInt(decodedList[2]);
final to = "0x" + decodedList[3];
final value = parseAsHexBigInt(decodedList[4]);
final data = decodedList[5].hexToBytes;
final v = parseAsHexInt(decodedList[6]);
final r = parseAsHexBigInt(decodedList[7]);
final s = parseAsHexBigInt(decodedList[8]);
return RawEVMTransactionType0(
nonce: nonce,
gasPrice: gasPrice,
gasLimit: gasLimit,
to: to,
value: value,
data: data,
v: v,
r: r,
s: s,
);
}