eth 0.4.12 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/codeql.yml +44 -0
- data/.github/workflows/docs.yml +26 -0
- data/.github/workflows/spec.yml +41 -0
- data/.gitignore +42 -9
- data/.gitmodules +3 -3
- data/AUTHORS.txt +16 -0
- data/CHANGELOG.md +18 -13
- data/Gemfile +15 -2
- data/LICENSE.txt +202 -21
- data/README.md +157 -81
- data/bin/console +4 -5
- data/bin/setup +4 -2
- data/eth.gemspec +46 -24
- data/lib/eth/abi/constant.rb +63 -0
- data/lib/eth/abi/type.rb +177 -0
- data/lib/eth/abi.rb +390 -0
- data/lib/eth/address.rb +48 -11
- data/lib/eth/chain.rb +148 -0
- data/lib/eth/eip712.rb +184 -0
- data/lib/eth/key/decrypter.rb +118 -88
- data/lib/eth/key/encrypter.rb +176 -99
- data/lib/eth/key.rb +131 -48
- data/lib/eth/signature.rb +160 -0
- data/lib/eth/tx/eip1559.rb +329 -0
- data/lib/eth/tx/eip2930.rb +321 -0
- data/lib/eth/tx/legacy.rb +293 -0
- data/lib/eth/tx.rb +274 -143
- data/lib/eth/unit.rb +49 -0
- data/lib/eth/util.rb +178 -0
- data/lib/eth/version.rb +18 -1
- data/lib/eth.rb +27 -67
- metadata +50 -61
- data/.travis.yml +0 -10
- data/lib/eth/gas.rb +0 -9
- data/lib/eth/open_ssl.rb +0 -264
- data/lib/eth/secp256k1.rb +0 -7
- data/lib/eth/sedes.rb +0 -40
- data/lib/eth/utils.rb +0 -130
data/lib/eth/tx.rb
CHANGED
@@ -1,197 +1,328 @@
|
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Eth Contributors
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "rlp"
|
16
|
+
require "konstructor"
|
17
|
+
|
18
|
+
require "eth/chain"
|
19
|
+
require "eth/tx/eip1559"
|
20
|
+
require "eth/tx/eip2930"
|
21
|
+
require "eth/tx/legacy"
|
22
|
+
require "eth/unit"
|
23
|
+
|
24
|
+
# Provides the `Eth` module.
|
1
25
|
module Eth
|
2
|
-
class Tx
|
3
26
|
|
4
|
-
|
5
|
-
|
27
|
+
# Provides the `Tx` module supporting various transaction types.
|
28
|
+
module Tx
|
29
|
+
extend self
|
6
30
|
|
7
|
-
|
8
|
-
|
9
|
-
gas_price: big_endian_int,
|
10
|
-
gas_limit: big_endian_int,
|
11
|
-
to: address,
|
12
|
-
value: big_endian_int,
|
13
|
-
data_bin: binary,
|
14
|
-
v: big_endian_int,
|
15
|
-
r: big_endian_int,
|
16
|
-
s: big_endian_int
|
17
|
-
})
|
31
|
+
# Provides a special transactoin error if transaction type is unknown.
|
32
|
+
class TransactionTypeError < TypeError; end
|
18
33
|
|
19
|
-
|
34
|
+
# Provides an decoder error if transaction cannot be decoded.
|
35
|
+
class DecoderError < StandardError; end
|
20
36
|
|
21
|
-
|
22
|
-
|
23
|
-
txh = deserialize(RLP.decode data).to_h
|
37
|
+
# Provides a parameter error if parameter types are invalid.
|
38
|
+
class ParameterError < TypeError; end
|
24
39
|
|
25
|
-
|
40
|
+
# The minimum transaction gas limit required for a value transfer.
|
41
|
+
DEFAULT_GAS_LIMIT = 21_000.freeze
|
26
42
|
|
27
|
-
|
28
|
-
|
43
|
+
# The "default" transaction gas price of 20 GWei. Do not use.
|
44
|
+
DEFAULT_GAS_PRICE = (20 * Unit::GWEI).freeze
|
29
45
|
|
30
|
-
|
31
|
-
|
32
|
-
fields[:to] = Utils.normalize_address(fields[:to])
|
46
|
+
# The calldata gas cost of a non-zero byte as per EIP-2028.
|
47
|
+
COST_NON_ZERO_BYTE = 16.freeze
|
33
48
|
|
34
|
-
|
49
|
+
# The calldata gas cost of a zero byte.
|
50
|
+
COST_ZERO_BYTE = 4.freeze
|
35
51
|
|
36
|
-
|
37
|
-
|
38
|
-
fields[:data_bin] = data_bin
|
39
|
-
end
|
40
|
-
serializable_initialize fields
|
52
|
+
# The access list gas cost of a storage key as per EIP-2930.
|
53
|
+
COST_STORAGE_KEY = 1_900.freeze
|
41
54
|
|
42
|
-
|
43
|
-
|
55
|
+
# The access list gas cost of an address as per EIP-2930.
|
56
|
+
COST_ADDRESS = 2_400.freeze
|
44
57
|
|
45
|
-
|
46
|
-
|
47
|
-
RLP.encode(us, sedes: us.sedes)
|
48
|
-
end
|
58
|
+
# The maximum transaction gas limit is bound by the block gas limit.
|
59
|
+
BLOCK_GAS_LIMIT = 25_000_000.freeze
|
49
60
|
|
50
|
-
|
51
|
-
|
52
|
-
end
|
61
|
+
# The legacy transaction type is 0.
|
62
|
+
TYPE_LEGACY = 0x00.freeze
|
53
63
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
64
|
+
# The EIP-2930 transaction type is 1.
|
65
|
+
TYPE_2930 = 0x01.freeze
|
57
66
|
|
58
|
-
|
59
|
-
|
60
|
-
end
|
67
|
+
# The EIP-1559 transaction type is 2.
|
68
|
+
TYPE_1559 = 0x02.freeze
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
vrs = Utils.v_r_s_for sig
|
65
|
-
self.v = (self.chain_id) ? ((self.chain_id * 2) + vrs[0] + 8) : vrs[0]
|
66
|
-
self.r = vrs[1]
|
67
|
-
self.s = vrs[2]
|
70
|
+
# The zero byte is 0x00.
|
71
|
+
ZERO_BYTE = "\x00".freeze
|
68
72
|
|
69
|
-
|
70
|
-
|
71
|
-
|
73
|
+
# Creates a new transaction of any type for given parameters and chain ID.
|
74
|
+
# Required parameters are (optional in brackets):
|
75
|
+
# - EIP-1559: chain_id, nonce, priority_fee, max_gas_fee, gas_limit(, from, to,
|
76
|
+
# value, data, access_list)
|
77
|
+
# - EIP-2930: chain_id, nonce, gas_price, gas_limit, access_list(, from, to,
|
78
|
+
# value, data)
|
79
|
+
# - Legacy: nonce, gas_price, gas_lmit(, from, to, value, data)
|
80
|
+
#
|
81
|
+
# @param params [Hash] all necessary transaction fields.
|
82
|
+
# @param chain_id [Integer] the EIP-155 Chain ID (legacy transactions only).
|
83
|
+
def new(params, chain_id = Chain::ETHEREUM)
|
72
84
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
85
|
+
# if we deal with max gas fee parameter, attempt EIP-1559
|
86
|
+
unless params[:max_gas_fee].nil?
|
87
|
+
params[:chain_id] = chain_id if params[:chain_id].nil?
|
88
|
+
return Tx::Eip1559.new params
|
77
89
|
end
|
78
|
-
end
|
79
90
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
91
|
+
# if we deal with access list parameter, attempt EIP-2930
|
92
|
+
unless params[:access_list].nil?
|
93
|
+
params[:chain_id] = chain_id if params[:chain_id].nil?
|
94
|
+
return Tx::Eip2930.new params
|
84
95
|
end
|
85
|
-
end
|
86
96
|
|
87
|
-
|
88
|
-
|
89
|
-
|
97
|
+
# if nothing else, go with legacy transactions
|
98
|
+
chain_id = params[:chain_id] if !params[:chain_id].nil? and params[:chain_id] != chain_id
|
99
|
+
return Tx::Legacy.new params, chain_id
|
90
100
|
end
|
91
101
|
|
92
|
-
|
93
|
-
|
102
|
+
# Decodes a transaction hex of any known type (2, 1, or legacy).
|
103
|
+
#
|
104
|
+
# @param hex [String] the raw transaction hex-string.
|
105
|
+
# @return [Eth::Tx] transaction payload.
|
106
|
+
# @raise [TransactionTypeError] if the transaction type is unknown.
|
107
|
+
def decode(hex)
|
108
|
+
hex = Util.remove_hex_prefix hex
|
109
|
+
type = hex[0, 2].to_i(16)
|
110
|
+
case type
|
111
|
+
when TYPE_1559
|
112
|
+
|
113
|
+
# EIP-1559 transaction (type 2)
|
114
|
+
return Tx::Eip1559.decode hex
|
115
|
+
when TYPE_2930
|
116
|
+
|
117
|
+
# EIP-2930 transaction (type 1)
|
118
|
+
return Tx::Eip2930.decode hex
|
119
|
+
else
|
94
120
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
].join
|
121
|
+
# Legacy transaction if first byte is RLP (>= 192)
|
122
|
+
if type >= 0xc0
|
123
|
+
return Tx::Legacy.decode hex
|
124
|
+
else
|
125
|
+
raise TransactionTypeError, "Cannot decode unknown transaction type #{type}!"
|
126
|
+
end
|
102
127
|
end
|
103
128
|
end
|
104
129
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
def
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
130
|
+
# Creates an unsigned copy of any transaction object.
|
131
|
+
#
|
132
|
+
# @param tx [Eth::Tx] any transaction payload.
|
133
|
+
# @return [Eth::Tx] an unsigned transaction payload of the same type.
|
134
|
+
# @raise [TransactionTypeError] if the transaction type is unknown.
|
135
|
+
def unsigned_copy(tx)
|
136
|
+
case tx.type
|
137
|
+
when TYPE_1559
|
138
|
+
|
139
|
+
# EIP-1559 transaction (type 2)
|
140
|
+
return Tx::Eip1559.unsigned_copy tx
|
141
|
+
when TYPE_2930
|
142
|
+
|
143
|
+
# EIP-2930 transaction (type 1)
|
144
|
+
return Tx::Eip2930.unsigned_copy tx
|
145
|
+
when TYPE_LEGACY
|
146
|
+
|
147
|
+
# Legacy transaction ("type 0")
|
148
|
+
return Tx::Legacy.unsigned_copy tx
|
149
|
+
end
|
150
|
+
raise TransactionTypeError, "Cannot copy unknown transaction type #{tx.type}!"
|
120
151
|
end
|
121
152
|
|
122
|
-
|
123
|
-
|
124
|
-
|
153
|
+
# Estimates intrinsic gas for provided call data (EIP-2028) and
|
154
|
+
# access lists (EIP-2930).
|
155
|
+
#
|
156
|
+
# @param data [String] the call data.
|
157
|
+
# @param list [Array] the access list.
|
158
|
+
# @return [Integer] the estimated intrinsic gas cost.
|
159
|
+
def estimate_intrinsic_gas(data = "", list = [])
|
160
|
+
gas = DEFAULT_GAS_LIMIT
|
161
|
+
unless data.nil? or data.empty?
|
162
|
+
data = Util.hex_to_bin data if Util.is_hex? data
|
163
|
+
|
164
|
+
# count zero bytes
|
165
|
+
zero = data.count ZERO_BYTE
|
166
|
+
gas += zero * COST_ZERO_BYTE
|
167
|
+
|
168
|
+
# count non-zero bytes
|
169
|
+
none = data.size - zero
|
170
|
+
gas += none * COST_NON_ZERO_BYTE
|
171
|
+
end
|
172
|
+
unless list.nil? or list.empty?
|
173
|
+
list.each do |entry|
|
125
174
|
|
126
|
-
|
127
|
-
|
128
|
-
end
|
175
|
+
# count addresses
|
176
|
+
gas += COST_ADDRESS
|
129
177
|
|
130
|
-
|
131
|
-
if cid != @chain_id
|
132
|
-
self.v = 0
|
133
|
-
self.r = 0
|
134
|
-
self.s = 0
|
178
|
+
entry.last.each do |key|
|
135
179
|
|
136
|
-
|
180
|
+
# count storage keys
|
181
|
+
gas += COST_STORAGE_KEY
|
182
|
+
end
|
183
|
+
end
|
137
184
|
end
|
138
|
-
|
139
|
-
@chain_id = (cid == 0) ? nil : cid
|
185
|
+
return gas
|
140
186
|
end
|
141
187
|
|
142
|
-
|
143
|
-
|
188
|
+
# Validates the common type-2 transaction fields such as nonce, priority
|
189
|
+
# fee, max gas fee, gas limit, amount, and access list.
|
190
|
+
#
|
191
|
+
# @param fields [Hash] the transaction fields.
|
192
|
+
# @return [Hash] the validated transaction fields.
|
193
|
+
# @raise [ParameterError] if nonce is an invalid integer.
|
194
|
+
# @raise [ParameterError] if priority fee is invalid.
|
195
|
+
# @raise [ParameterError] if max gas fee is invalid.
|
196
|
+
# @raise [ParameterError] if gas limit is invalid.
|
197
|
+
# @raise [ParameterError] if amount is invalid.
|
198
|
+
# @raise [ParameterError] if access list is invalid.
|
199
|
+
def validate_params(fields)
|
200
|
+
unless fields[:nonce] >= 0
|
201
|
+
raise ParameterError, "Invalid signer nonce #{fields[:nonce]}!"
|
202
|
+
end
|
203
|
+
unless fields[:priority_fee] >= 0
|
204
|
+
raise ParameterError, "Invalid gas priority fee #{fields[:priority_fee]}!"
|
205
|
+
end
|
206
|
+
unless fields[:max_gas_fee] >= 0
|
207
|
+
raise ParameterError, "Invalid max gas fee #{fields[:max_gas_fee]}!"
|
208
|
+
end
|
209
|
+
unless fields[:gas_limit] >= DEFAULT_GAS_LIMIT and fields[:gas_limit] <= BLOCK_GAS_LIMIT
|
210
|
+
raise ParameterError, "Invalid gas limit #{fields[:gas_limit]}!"
|
211
|
+
end
|
212
|
+
unless fields[:value] >= 0
|
213
|
+
raise ParameterError, "Invalid transaction value #{fields[:value]}!"
|
214
|
+
end
|
215
|
+
unless fields[:access_list].nil? or fields[:access_list].is_a? Array
|
216
|
+
raise ParameterError, "Invalid access list #{fields[:access_list]}!"
|
217
|
+
end
|
218
|
+
return fields
|
144
219
|
end
|
145
220
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
221
|
+
# Validates the common legacy transaction fields such as nonce, gas
|
222
|
+
# price, gas limit, amount, and access list.
|
223
|
+
#
|
224
|
+
# @param fields [Hash] the transaction fields.
|
225
|
+
# @return [Hash] the validated transaction fields.
|
226
|
+
# @raise [ParameterError] if nonce is an invalid integer.
|
227
|
+
# @raise [ParameterError] if gas price is invalid.
|
228
|
+
# @raise [ParameterError] if gas limit is invalid.
|
229
|
+
# @raise [ParameterError] if amount is invalid.
|
230
|
+
# @raise [ParameterError] if access list is invalid.
|
231
|
+
def validate_legacy_params(fields)
|
232
|
+
unless fields[:nonce] >= 0
|
233
|
+
raise ParameterError, "Invalid signer nonce #{fields[:nonce]}!"
|
234
|
+
end
|
235
|
+
unless fields[:gas_price] >= 0
|
236
|
+
raise ParameterError, "Invalid gas price #{fields[:gas_price]}!"
|
237
|
+
end
|
238
|
+
unless fields[:gas_limit] >= DEFAULT_GAS_LIMIT and fields[:gas_limit] <= BLOCK_GAS_LIMIT
|
239
|
+
raise ParameterError, "Invalid gas limit #{fields[:gas_limit]}!"
|
240
|
+
end
|
241
|
+
unless fields[:value] >= 0
|
242
|
+
raise ParameterError, "Invalid transaction value #{fields[:value]}!"
|
243
|
+
end
|
244
|
+
unless fields[:access_list].nil? or fields[:access_list].is_a? Array
|
245
|
+
raise ParameterError, "Invalid access list #{fields[:access_list]}!"
|
246
|
+
end
|
247
|
+
return fields
|
151
248
|
end
|
152
249
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
250
|
+
# Populates the transaction chain id field with a serializable default
|
251
|
+
# value (1) in case it is undefined.
|
252
|
+
#
|
253
|
+
# @param id [Integer] the transaction chain id.
|
254
|
+
# @return [Integer] the sanitized transaction chain id.
|
255
|
+
def sanitize_chain(id)
|
256
|
+
id = Chain::ETHEREUM if id.nil?
|
257
|
+
return id
|
157
258
|
end
|
158
259
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
260
|
+
# Populates the transaction destination address with a serializable
|
261
|
+
# empty value in case it is undefined; also ensures the address is
|
262
|
+
# checksummed but not prefixed for consistency.
|
263
|
+
#
|
264
|
+
# @param addr [String] the transaction destination address.
|
265
|
+
# @return [String] the sanitized transaction destination address.
|
266
|
+
def sanitize_address(addr)
|
267
|
+
addr = "" if addr.nil?
|
268
|
+
if addr.is_a? String and !addr.empty?
|
269
|
+
addr = Address.new(addr).to_s
|
270
|
+
addr = Util.remove_hex_prefix addr
|
164
271
|
end
|
272
|
+
return addr
|
165
273
|
end
|
166
274
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
def signature_hash
|
177
|
-
Utils.keccak256 unsigned_encoded
|
275
|
+
# Populates the transaction value field with a serializable empty value
|
276
|
+
# in case it is undefined.
|
277
|
+
#
|
278
|
+
# @param val [Integer] the transaction value.
|
279
|
+
# @return [Integer] the sanitized transaction value.
|
280
|
+
def sanitize_amount(val)
|
281
|
+
val = 0 if val.nil?
|
282
|
+
return val
|
178
283
|
end
|
179
284
|
|
180
|
-
|
181
|
-
|
285
|
+
# Populates the transaction payload field with a serializable empty value
|
286
|
+
# in case it is undefined; also ensures the data is binary not hex.
|
287
|
+
#
|
288
|
+
# @param data [String] the transaction payload data.
|
289
|
+
# @return [String] the sanitized transaction payload data.
|
290
|
+
def sanitize_data(data)
|
291
|
+
data = "" if data.nil?
|
292
|
+
|
293
|
+
# ensure payload to be binary if it's hex, otherwise we'll treat it raw
|
294
|
+
data = Util.hex_to_bin data if Util.is_hex? data
|
295
|
+
return data
|
182
296
|
end
|
183
297
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
298
|
+
# Populates the transaction access list field with a serializable empty
|
299
|
+
# array in case it is undefined; also ensures the nested data is binary
|
300
|
+
# not hex.
|
301
|
+
#
|
302
|
+
# @param list [Array] the transaction access list.
|
303
|
+
# @return [Array] the sanitized transaction access list.
|
304
|
+
def sanitize_list(list)
|
305
|
+
list = [] if list.nil?
|
306
|
+
list.each_with_index do |value, index|
|
307
|
+
if value.is_a? Array
|
308
|
+
|
309
|
+
# recursively check the entire array
|
310
|
+
list[index] = sanitize_list value
|
311
|
+
elsif Util.is_hex? value
|
312
|
+
|
313
|
+
# only modify if we find a hex value
|
314
|
+
list[index] = Util.hex_to_bin value
|
315
|
+
end
|
191
316
|
end
|
317
|
+
return list
|
192
318
|
end
|
193
319
|
|
320
|
+
# Allows to check wether a transaction is signed already.
|
321
|
+
#
|
322
|
+
# @return [Bool] true if transaction is already signed.
|
323
|
+
def is_signed?(tx)
|
324
|
+
!tx.signature_r.nil? and tx.signature_r != 0 and
|
325
|
+
!tx.signature_s.nil? and tx.signature_s != 0
|
326
|
+
end
|
194
327
|
end
|
195
|
-
|
196
|
-
UnsignedTx = Tx.exclude([:v, :r, :s])
|
197
328
|
end
|
data/lib/eth/unit.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2016-2022 The Ruby-Eth Contributors
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require "bigdecimal"
|
16
|
+
|
17
|
+
# Provides the `Eth` module.
|
18
|
+
module Eth
|
19
|
+
|
20
|
+
# Provides constants for common Ethereum units.
|
21
|
+
module Unit
|
22
|
+
extend self
|
23
|
+
|
24
|
+
# Ethereum unit 1 wei := 0.000000000000000001 Ether.
|
25
|
+
WEI = BigDecimal("1e0").freeze
|
26
|
+
|
27
|
+
# Ethereum unit 1 babbage := 0.000000000000001 Ether or 1_000 wei.
|
28
|
+
BABBAGE = BigDecimal("1e3").freeze
|
29
|
+
|
30
|
+
# Ethereum unit 1 lovelace := 0.000000000001 Ether or 1_000_000 wei.
|
31
|
+
LOVELACE = BigDecimal("1e6").freeze
|
32
|
+
|
33
|
+
# Ethereum unit 1 shannon := 0.000000001 Ether or 1_000_000_000 wei.
|
34
|
+
SHANNON = BigDecimal("1e9").freeze
|
35
|
+
|
36
|
+
# Ethereum unit 1 szabo := 0.000_001 Ether or 1_000_000_000_000 wei.
|
37
|
+
SZABO = BigDecimal("1e12").freeze
|
38
|
+
|
39
|
+
# Ethereum unit 1 finney := 0.001 Ether or 1_000_000_000_000_000 wei.
|
40
|
+
FINNEY = BigDecimal("1e15").freeze
|
41
|
+
|
42
|
+
# Ethereum unit 1 Ether := 1_000_000_000_000_000_000 wei.
|
43
|
+
ETHER = BigDecimal("1e18").freeze
|
44
|
+
|
45
|
+
# Ethereum unit 1 Gwei := 0.000000001 Ether or 1_000_000_000 wei.
|
46
|
+
# Same as shannon, but more commonly used (billion wei).
|
47
|
+
GWEI = SHANNON.freeze
|
48
|
+
end
|
49
|
+
end
|