nim-ethers/ethers/transaction.nim

30 lines
830 B
Nim
Raw Permalink Normal View History

2022-01-20 11:56:18 +00:00
import pkg/stew/byteutils
import ./basics
type Transaction* = object
2022-01-24 13:40:47 +00:00
sender*: ?Address
2022-01-20 11:56:18 +00:00
to*: Address
data*: seq[byte]
2022-01-25 09:25:09 +00:00
nonce*: ?UInt256
chainId*: ?UInt256
gasPrice*: ?UInt256
maxFee*: ?UInt256
maxPriorityFee*: ?UInt256
2022-01-25 09:25:09 +00:00
gasLimit*: ?UInt256
2022-01-20 11:56:18 +00:00
func `$`*(transaction: Transaction): string =
2022-01-24 13:40:47 +00:00
result = "("
if sender =? transaction.sender:
result &= "from: " & $sender & ", "
result &= "to: " & $transaction.to & ", "
result &= "data: 0x" & $transaction.data.toHex
2022-01-25 09:25:09 +00:00
if nonce =? transaction.nonce:
result &= ", nonce: 0x" & $nonce.toHex
if chainId =? transaction.chainId:
result &= ", chainId: " & $chainId
if gasPrice =? transaction.gasPrice:
result &= ", gasPrice: 0x" & $gasPrice.toHex
if gasLimit =? transaction.gasLimit:
result &= ", gasLimit: 0x" & $gasLimit.toHex
2022-01-24 13:40:47 +00:00
result &= ")"