2019-03-23 20:54:28 +00:00
import
2021-06-01 13:16:03 +00:00
hexstrings , options , eth / [ common , keys , rlp ] , json
2018-08-13 18:25:21 +00:00
#[
Notes :
* Some of the types suppose ' n u l l ' when there is no appropriate value .
2018-08-28 20:37:44 +00:00
To allow for this , you can use Option [ T ] or use refs so the JSON transform can convert to ` JNull ` .
2018-08-15 12:14:32 +00:00
* Parameter objects from users must have their data verified so will use EthAddressStr instead of EthAddres , for example
* Objects returned to the user can use native Nimbus types , where hexstrings provides converters to hex strings .
This is because returned arrays in JSON is
a ) not an efficient use of space
b ) not the format the user expects ( for example addresses are expected to be hex strings prefixed by " 0x " )
2018-08-13 18:25:21 +00:00
] #
type
SyncState * = object
2018-08-15 12:14:32 +00:00
# Returned to user
2020-07-22 16:51:26 +00:00
startingBlock * : HexQuantityStr # BlockNumber
currentBlock * : HexQuantityStr # BlockNumber
highestBlock * : HexQuantityStr # BlockNumber
2018-08-13 18:25:21 +00:00
2020-07-23 15:30:42 +00:00
TxSend * = object
2018-08-15 12:14:32 +00:00
# Parameter from user
2020-07-23 15:30:42 +00:00
source * : EthAddressStr # 20 bytes, the address the transaction is send from.
to * : Option [ EthAddressStr ] # (optional when creating new contract) 20 bytes, the address the transaction is directed to.
gas * : Option [ HexQuantityStr ] # (optional, default: 90000) integer of the gas provided for the transaction execution. It will return unused gas.
gasPrice * : Option [ HexQuantityStr ] # (optional, default: To-Be-Determined) integer of the gasPrice used for each paid gas.
value * : Option [ HexQuantityStr ] # (optional) integer of the value sent with this transaction.
data * : HexDataStr # TODO: Support more data. The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Ethereum Contract ABI.
nonce * : Option [ HexQuantityStr ] # (optional) integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce
2018-08-13 18:25:21 +00:00
2018-10-16 00:10:01 +00:00
EthCall * = object
2018-08-15 12:14:32 +00:00
# Parameter from user
2020-07-24 12:44:36 +00:00
source * : Option [ EthAddressStr ] # (optional) The address the transaction is send from.
to * : Option [ EthAddressStr ] # (optional in eth_estimateGas, not in eth_call) The address the transaction is directed to.
2020-07-29 05:42:32 +00:00
gas * : Option [ HexQuantityStr ] # (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.
2020-07-24 12:44:36 +00:00
gasPrice * : Option [ HexQuantityStr ] # (optional) Integer of the gasPrice used for each paid gas.
value * : Option [ HexQuantityStr ] # (optional) Integer of the value sent with this transaction.
2020-07-28 16:48:45 +00:00
data * : Option [ EthHashStr ] # (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI.
2018-08-13 18:25:21 +00:00
## A block object, or null when no block was found
2019-02-05 19:15:50 +00:00
## Note that this includes slightly different information from eth/common.BlockHeader
2018-08-28 20:37:44 +00:00
BlockObject * = object
2018-08-15 12:14:32 +00:00
# Returned to user
2020-07-30 07:21:11 +00:00
number * : Option [ HexQuantityStr ] # the block number. null when its pending block.
2018-08-28 20:37:44 +00:00
hash * : Option [ Hash256 ] # hash of the block. null when its pending block.
2018-08-15 12:14:32 +00:00
parentHash * : Hash256 # hash of the parent block.
2020-07-30 07:21:11 +00:00
nonce * : Option [ HexDataStr ] # hash of the generated proof-of-work. null when its pending block.
2018-08-15 12:14:32 +00:00
sha3Uncles * : Hash256 # SHA3 of the uncles data in the block.
2018-08-28 20:37:44 +00:00
logsBloom * : Option [ BloomFilter ] # the bloom filter for the logs of the block. null when its pending block.
2018-08-15 12:14:32 +00:00
transactionsRoot * : Hash256 # the root of the transaction trie of the block.
stateRoot * : Hash256 # the root of the final state trie of the block.
receiptsRoot * : Hash256 # the root of the receipts trie of the block.
miner * : EthAddress # the address of the beneficiary to whom the mining rewards were given.
2020-07-30 07:21:11 +00:00
difficulty * : HexQuantityStr # integer of the difficulty for this block.
totalDifficulty * : HexQuantityStr # integer of the total difficulty of the chain until this block.
extraData * : HexDataStr # the "extra data" field of this block.
size * : HexQuantityStr # integer the size of this block in bytes.
gasLimit * : HexQuantityStr # the maximum gas allowed in this block.
gasUsed * : HexQuantityStr # the total used gas by all transactions in this block.
timestamp * : HexQuantityStr # the unix timestamp for when the block was collated.
transactions * : seq [ JsonNode ] # list of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
2018-08-20 19:51:25 +00:00
uncles * : seq [ Hash256 ] # list of uncle hashes.
2018-08-13 18:25:21 +00:00
TransactionObject * = object # A transaction object, or null when no transaction was found:
2018-08-15 12:14:32 +00:00
# Returned to user
2018-08-28 20:37:44 +00:00
blockHash * : Option [ Hash256 ] # hash of the block where this transaction was in. null when its pending.
2020-07-30 07:21:11 +00:00
blockNumber * : Option [ HexQuantityStr ] # block number where this transaction was in. null when its pending.
` from ` * : EthAddress # address of the sender.
gas * : HexQuantityStr # gas provided by the sender.
gasPrice * : HexQuantityStr # gas price provided by the sender in Wei.
hash * : Hash256 # hash of the transaction.
2018-08-28 20:37:44 +00:00
input * : Blob # the data send along with the transaction.
2020-07-30 07:21:11 +00:00
nonce * : HexQuantityStr # the number of transactions made by the sender prior to this one.
to * : Option [ EthAddress ] # address of the receiver. null when its a contract creation transaction.
transactionIndex * : Option [ HexQuantityStr ] # integer of the transactions index position in the block. null when its pending.
value * : HexQuantityStr # value transferred in Wei.
v * : HexQuantityStr # ECDSA recovery id
r * : HexQuantityStr # 32 Bytes - ECDSA signature r
s * : HexQuantityStr # 32 Bytes - ECDSA signature s
2018-08-13 18:25:21 +00:00
2018-08-22 16:39:42 +00:00
FilterLog * = object
2018-08-15 12:14:32 +00:00
# Returned to user
2018-08-28 20:37:44 +00:00
removed * : bool # true when the log was removed, due to a chain reorganization. false if its a valid log.
logIndex * : Option [ int ] # integer of the log index position in the block. null when its pending log.
transactionIndex * : Option [ int ] # integer of the transactions index position log was created from. null when its pending log.
transactionHash * : Option [ Hash256 ] # hash of the transactions this log was created from. null when its pending log.
blockHash * : Option [ Hash256 ] # hash of the block where this log was in. null when its pending. null when its pending log.
blockNumber * : Option [ BlockNumber ] # the block number where this log was in. null when its pending. null when its pending log.
address * : EthAddress # address from which this log originated.
data * : seq [ Hash256 ] # contains one or more 32 Bytes non-indexed arguments of the log.
topics * : array [ 4 , Hash256 ] # array of 0 to 4 32 Bytes DATA of indexed log arguments.
# (In solidity: The first topic is the hash of the signature of the event.
# (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
2018-08-17 22:51:05 +00:00
ReceiptObject * = object
# A transaction receipt object, or null when no receipt was found:
2018-08-28 20:37:44 +00:00
transactionHash * : Hash256 # hash of the transaction.
2020-07-30 07:21:11 +00:00
transactionIndex * : HexQuantityStr # integer of the transactions index position in the block.
2018-08-28 20:37:44 +00:00
blockHash * : Hash256 # hash of the block where this transaction was in.
2020-07-30 07:21:11 +00:00
blockNumber * : HexQuantityStr # block number where this transaction was in.
` from ` * : EthAddress # address of the sender.
2018-08-28 20:37:44 +00:00
to * : Option [ EthAddress ] # address of the receiver. null when its a contract creation transaction.
2020-07-30 07:21:11 +00:00
cumulativeGasUsed * : HexQuantityStr # the total amount of gas used when this transaction was executed in the block.
gasUsed * : HexQuantityStr # the amount of gas used by this specific transaction alone.
2018-08-28 20:37:44 +00:00
contractAddress * : Option [ EthAddress ] # the contract address created, if the transaction was a contract creation, otherwise null.
logs * : seq [ Log ] # list of log objects which this transaction generated.
logsBloom * : BloomFilter # bloom filter for light clients to quickly retrieve related logs.
2018-11-28 15:04:57 +00:00
root * : Option [ Hash256 ] # post-transaction stateroot (pre Byzantium).
status * : Option [ int ] # 1 = success, 0 = failure.
2018-08-17 22:51:05 +00:00
2018-08-21 21:21:41 +00:00
FilterDataKind * = enum fkItem , fkList
FilterData * = object
# Difficult to process variant objects in input data, as kind is immutable.
# TODO: This might need more work to handle "or" options
kind * : FilterDataKind
items * : seq [ FilterData ]
item * : UInt256
FilterOptions * = object
# Parameter from user
2018-12-05 13:37:49 +00:00
fromBlock * : Option [ string ] # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
toBlock * : Option [ string ] # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions.
address * : Option [ EthAddress ] # (optional) contract address or a list of addresses from which logs should originate.
topics * : Option [ seq [ FilterData ] ] # (optional) list of DATA topics. Topics are order-dependent. Each topic can also be a list of DATA with "or" options.