line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
210767
|
use v5.26; |
|
3
|
|
|
|
|
32
|
|
2
|
3
|
|
|
3
|
|
1279
|
use Object::Pad ':experimental(init_expr)'; |
|
3
|
|
|
|
|
22552
|
|
|
3
|
|
|
|
|
18
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Blockchain::Ethereum::Transaction::EIP1559 0.006; |
5
|
|
|
|
|
|
|
class Blockchain::Ethereum::Transaction::EIP1559 |
6
|
2
|
|
|
2
|
|
1188
|
:does(Blockchain::Ethereum::Transaction); |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
170
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=encoding utf8 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Blockchain::Ethereum::Transaction::EIP1559 - Ethereum Fee Market transaction abstraction |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Transaction abstraction for EIP1559 Fee Market transactions |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $transaction = Blockchain::Ethereum::Transaction::EIP1559->new( |
19
|
|
|
|
|
|
|
nonce => '0x0', |
20
|
|
|
|
|
|
|
max_fee_per_gas => '0x9', |
21
|
|
|
|
|
|
|
max_priority_fee_per_gas => '0x0', |
22
|
|
|
|
|
|
|
gas_limit => '0x1DE2B9', |
23
|
|
|
|
|
|
|
to => '0x3535353535353535353535353535353535353535' |
24
|
|
|
|
|
|
|
value => '0xDE0B6B3A7640000', |
25
|
|
|
|
|
|
|
data => '0x', |
26
|
|
|
|
|
|
|
chain_id => '0x539' |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# github.com/refeco/perl-ethereum-keystore |
30
|
|
|
|
|
|
|
my $key = Blockchain::Ethereum::Keystore::Key->new( |
31
|
|
|
|
|
|
|
private_key => pack "H*", |
32
|
|
|
|
|
|
|
'4646464646464646464646464646464646464646464646464646464646464646' |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$key->sign_transaction($transaction); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $raw_transaction = $transaction->serialize; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
3
|
|
836
|
use constant TRANSACTION_PREFIX => pack("H*", '02'); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2810
|
|
42
|
|
|
|
|
|
|
|
43
|
6
|
|
|
6
|
0
|
14
|
field $max_priority_fee_per_gas :reader :writer :param; |
|
6
|
|
|
0
|
0
|
40
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
44
|
6
|
|
|
6
|
0
|
16
|
field $max_fee_per_gas :reader :writer :param; |
|
6
|
|
|
0
|
0
|
30
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
45
|
6
|
|
|
6
|
0
|
18
|
field $access_list :reader :writer :param = []; |
46
|
|
|
|
|
|
|
|
47
|
6
|
|
|
0
|
0
|
26
|
=head2 serialize |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Encodes the given transaction parameters to RLP |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Usage: |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
serialize() -> RLP encoded transaction bytes |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over 4 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Returns the RLP encoded transaction bytes |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
|
63
|
6
|
|
|
6
|
1
|
74
|
method serialize() { |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
13
|
|
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
41
|
my @params = ( |
66
|
|
|
|
|
|
|
$self->chain_id, # |
67
|
|
|
|
|
|
|
$self->nonce, |
68
|
|
|
|
|
|
|
$self->max_priority_fee_per_gas, |
69
|
|
|
|
|
|
|
$self->max_fee_per_gas, |
70
|
|
|
|
|
|
|
$self->gas_limit, |
71
|
|
|
|
|
|
|
$self->to, |
72
|
|
|
|
|
|
|
$self->value, |
73
|
|
|
|
|
|
|
$self->data, |
74
|
|
|
|
|
|
|
$self->access_list, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
6
|
|
|
|
|
37
|
@params = $self->_equalize_params(\@params)->@*; |
78
|
|
|
|
|
|
|
|
79
|
6
|
50
|
66
|
|
|
46
|
push(@params, $self->v, $self->r, $self->s) |
|
|
|
66
|
|
|
|
|
80
|
|
|
|
|
|
|
if $self->v && $self->r && $self->s; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# eip-1559 transactions must be prefixed by 2 that is the |
83
|
|
|
|
|
|
|
# transaction type |
84
|
6
|
|
|
|
|
31
|
return TRANSACTION_PREFIX . $self->rlp->encode(\@params); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 generate_v |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Generate the transaction v field using the given y-parity |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Usage: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
generate_v($y_parity) -> hexadecimal v |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 4 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * C<$y_parity> y-parity |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns the v hexadecimal value also sets the v fields from transaction |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
2
|
|
|
2
|
1
|
20
|
method generate_v ($y_parity) { |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
4
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# eip-1559 uses y directly as the v point |
108
|
|
|
|
|
|
|
# instead of using recovery id as the legacy |
109
|
|
|
|
|
|
|
# transactions |
110
|
2
|
|
|
|
|
23
|
my $v = sprintf("0x%x", $y_parity); |
111
|
2
|
|
|
|
|
11
|
$self->set_v($v); |
112
|
2
|
|
|
|
|
6
|
return $v; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
__END__ |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Reginaldo Costa, C<< <refeco at cpan.org> >> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 BUGS |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Please report any bugs or feature requests to L<https://github.com/refeco/perl-ethereum-transaction> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This software is Copyright (c) 2023 by REFECO. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is free software, licensed under: |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
The MIT License |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=cut |