Blockchain-Ethereum-Transaction

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

            max_priority_fee_per_gas => '0x0',
            gas_limit                => '0x1DE2B9',
            to                       => '0x3535353535353535353535353535353535353535'
            value                    => Math::BigInt->new('1000000000000000000'),
            data                     => '0x',
            chain_id                 => '0x539'
        );
    
        # github.com/refeco/perl-ethereum-keystore
        my $key = Blockchain::Ethereum::Keystore::Key->new(
            private_key => pack "H*",
            '4646464646464646464646464646464646464646464646464646464646464646'
        );
    
        $key->sign_transaction($transaction);
    
        my $raw_transaction = $transaction->serialize;
    
        print unpack("H*", $raw_transaction);

    Standalone version:

bin/ethereum-raw-tx  view on Meta::CPAN

use warnings;

use Carp;
use Getopt::Long;
use Pod::Usage;

use Blockchain::Ethereum::Transaction::Legacy;
use Blockchain::Ethereum::Transaction::EIP1559;
use Blockchain::Ethereum::Keystore::Key;

my ($tx_type, $chain_id, $nonce, $max_fee_per_gas, $max_priority_fee_per_gas, $gas_price, $gas_limit, $to, $value, $data, $private_key);
GetOptions(
    "tx-type=s"                => \$tx_type,
    "chain-id=s"               => \$chain_id,
    "nonce=s"                  => \$nonce,
    "max-fee-per-gas=s"        => \$max_fee_per_gas,
    "max-priority-fee-per-gas" => \$max_priority_fee_per_gas,
    "gas-price=s"              => \$gas_price,
    "gas-limit=s"              => \$gas_limit,
    "to=s"                     => \$to,
    "value=s"                  => \$value,
    "data=s"                   => \$data,
    "pk=s"                     => \$private_key
);

my %transaction_versions = (
    legacy  => "Blockchain::Ethereum::Transaction::Legacy",
    eip1559 => "Blockchain::Ethereum::Transaction::EIP1519",
);

pod2usage(1) unless $tx_type && $transaction_versions{$tx_type} && $nonce && $gas_limit;

my %params = (

lib/Blockchain/Ethereum/Transaction/EIP1559.pm  view on Meta::CPAN

        max_priority_fee_per_gas => '0x0',
        gas_limit                => '0x1DE2B9',
        to                       => '0x3535353535353535353535353535353535353535'
        value                    => '0xDE0B6B3A7640000',
        data                     => '0x',
        chain_id                 => '0x539'
    );

    # github.com/refeco/perl-ethereum-keystore
    my $key = Blockchain::Ethereum::Keystore::Key->new(
        private_key => pack "H*",
        '4646464646464646464646464646464646464646464646464646464646464646'
    );

    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

=head1 METHODS

=head2 serialize

lib/Blockchain/Ethereum/Transaction/Legacy.pm  view on Meta::CPAN

     my $transaction = Blockchain::Ethereum::Transaction::Legacy->new(
        nonce     => '0x9',
        gas_price => '0x4A817C800',
        gas_limit => '0x5208',
        to        => '0x3535353535353535353535353535353535353535',
        value     => '0xDE0B6B3A7640000',
        chain_id  => '0x1'

    # github.com/refeco/perl-ethereum-keystore
    my $key = Blockchain::Ethereum::Keystore::Key->new(
        private_key => pack "H*",
        '4646464646464646464646464646464646464646464646464646464646464646'
    );

    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

=head1 METHODS

=head2 serialize

t/eip1559.t  view on Meta::CPAN

        nonce                    => '0x0',
        max_fee_per_gas          => '0x9',
        max_priority_fee_per_gas => '0x0',
        gas_limit                => '0x1DE2B9',
        value                    => '0x0',
        data                     => $compiled_contract,
        chain_id                 => '0x539'
    );

    my $key = Blockchain::Ethereum::Keystore::Key->new(
        private_key => pack "H*",
        '4646464646464646464646464646464646464646464646464646464646464646'
    );

    $key->sign_transaction($transaction);

    my $raw_transaction = $transaction->serialize;

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

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.501 second using v1.00-cache-2.02-grep-82fe00e-cpan-dad7e4baca0 )