Skip to content

Transaction Format

zgw edited this page Jan 25, 2019 · 2 revisions

Here is the QuarkChain transaction defined in python.

fields = [
        ("nonce", big_endian_int),
        ("gasprice", big_endian_int),
        ("startgas", big_endian_int),
        ("to", utils.address),
        ("value", big_endian_int),
        ("data", binary),
        ("network_id", big_endian_int),
        ("from_full_shard_key", BigEndianInt(4)),
        ("to_full_shard_key", BigEndianInt(4)),
        ("gas_token_id", big_endian_int),
        ("transfer_token_id", big_endian_int),
        ("version", big_endian_int),
        ("v", big_endian_int),
        ("r", big_endian_int),
        ("s", big_endian_int),
    ]

6 fields are added onto the existing Ethereum transaction data structure.

Field Type Description
network_id int Identifies the network e.g. testnet, mainnet (similar to ethereum's chain id which is hacked into the 'v' field)
from_full_shard_key 4 bytes fixed int Identifies the source shard of the transaction
to_full_shard_key 4 bytes fixed int Identifies the destination shard of the transaction
gas_token_id int Identifies the token used for paying gas
transfer_token_id int Identifies the token used for value transfering
version int Identifies the signature style; 0: eth-style signature; 1: typed signature (EIP-712) as implemented by MetaMask before #4803

Note that when constructing a transaction, from_full_shard_key should be FULL_SHARD_KEY (the last 4 bytes) of the sender's address, to should be the RECIPIENT (first 20 bytes) of the receiver’s address, and to_full_shard_key should be the FULL_SHARD_KEY of the receiver's address. network_id should be the network ID the transaction is intended for, e.g., 3 for testnet.