Blockchain-Ethereum-Transaction

 view release on metacpan or  search on metacpan

t/eip1559.t  view on Meta::CPAN

    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

    is(unpack("H*", $raw_transaction),
        '02f901c3820539808009831de2b98080b90170608060405234801561001057600080fd5b50610150806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80632e64cec11461003b5780636057361d14610059575b600080fd5b610043610075565b604...
    );

    my $rlp = Blockchain::Ethereum::RLP->new();
    # substring to remove the 02
    my $decoded = $rlp->decode(substr($raw_transaction, 1));

    is hex $decoded->[-3], 0, 'correct eip155 v value for contract creation transaction';

};

subtest "eth transfer" => sub {
    my $transaction = Blockchain::Ethereum::Transaction::EIP1559->new(
        nonce                    => '0x1',
        max_fee_per_gas          => '0x9',
        max_priority_fee_per_gas => '0x0',
        gas_limit                => '0x5208',
        to                       => '0x3535353535353535353535353535353535353535',

t/eip1559.t  view on Meta::CPAN

    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

    is(unpack("H*", $raw_transaction),
        '02f86c820539018009825208943535353535353535353535353535353535353535880de0b6b3a764000080c080a070816c3d026c13a53e98e5dc414398e9dcdf23e440e777114a3e04810e0dfb5da07d732e6b7f847b06d2baed033772d78407da8f4010fa9300df79f2209ba4c7a0'
    );

    my $rlp = Blockchain::Ethereum::RLP->new();
    # substring to remove the 02
    my $decoded = $rlp->decode(substr($raw_transaction, 1));

    is hex $decoded->[-3], 0, 'correct eip155 v value for contract creation transaction';

};

done_testing;

t/legacy.t  view on Meta::CPAN


    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

    is(unpack("H*", $raw_transaction),
        'f86c098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a76400008025a028ef61340bd939bc2195fe537567866003e1a15d3c71ff63e1590620aa636276a067cbe9d8997f761aecb703304b3800ccf555c9f3dc64214b297fb1966a3b6d83'
    );

    my $rlp     = Blockchain::Ethereum::RLP->new();
    my $decoded = $rlp->decode($raw_transaction);

    is hex $decoded->[-3], 37, 'correct eip155 v value';
};

done_testing;



( run in 0.315 second using v1.01-cache-2.11-cpan-26ccb49234f )