The Transaction type
Table of contents |
---|
Deploy |
Version1 |
A transaction is an enum-type whose variants represent atomic units of work that can be sent to the node for execution.
Currently it consists of two possible variants:
- Deploy
- Version1
Deploy
The Transaction::Deploy variant is equivalent to the 1.x Deploy.
Serializing a Transaction
of variant Deploy
:
- The first byte is a
0
- Next bytes are binary representation of a Deploy
Version1
Transaction::Version1 is the new way that work can be proposed to a node. It's nature is more amorphic than Transaction::Deploy. This type of Transaction uses a self-describing binary serialization scheme (comparing to other Binary Serialization Standard types). The self-describing scheme is called Calltable serialization
in this document. An in-depth description of how this self-describing standard works is in the calltable serialization document. We will be using serialization_index
and variant discriminator
terms, their interpretation is explained in the calltable serialization document also.
Serializing a Transaction
of variant Version1
:
- The first byte is a
1
- Next bytes are binary representation of a TransactionV1
TransactionV1
TransactionV1
(serialized using calltable scheme) consists of:
hash
- hash calculated over binary serialization ofpayload
. It'sserialization_index
is0
. In the sense of binary serialization it is a Digestpayload
- of typeTransactionV1Payload
, contains all the actual data that the transaction sends to node. It'sserialization_index
is1
approvals
- collection of Approvals being signatures overhash
. It'sserialization_index
is2
TransactionV1Payload
TransactionV1Payload
(serialized using calltable scheme) consists of:
initiator_addr
- of type InitiatorAddr identifies the initiator of this Transaction. It'sserialization_index
is0
timestamp
- Timestamp identifying the self-declared time of creation for this transaction. It'sserialization_index
is1
ttl
- TimeDiff self-declared period in which the transaction should be included in a block and executed. It'sserialization_index
is2
chain_name
-String
identifying the network name on which this transaction should be executed. It'sserialization_index
is3
pricing_mode
- PricingMode declaration of how the transaction should be payed for. It'sserialization_index
is4
fields
- please see v1.payload.fields section. It'sserialization_index
is5
InitiatorAddr
InitiatorAddr
(serialized using calltable scheme) consists of:
- in variant InitiatorAddr::PublicKey
- variant discriminator of value
0
PublicKey
serialized under serialization key1
- variant discriminator of value
- in variant InitiatorAddr::AccountHash
- variant discriminator of value
1
AccountHash
serialized under serialization key1
- variant discriminator of value
PricingMode
PricingMode
(serialized using calltable scheme) consists of:
- in variant
PaymentLimited
- in variant
Fixed
- in variant
Prepaid
- variant discriminator of value
2
- field
receipt
of type Digest with serialization index1
- variant discriminator of value
V1.payload.fields
This is an amorphous data holder. It is serialized as an ordered collection of tuples holding (u16, Bytes). By u16 we understand an unsigned 2 byte number (see numeric). The invariants for this field are:
- keys (first tuple entries) are unique
- the collection is ordered ascending by first element of the tuple (u16)
Breaking the above invariants will cause the node to reject the the transaction as malformed.
This field is design in this amorphous way to facilitate the possibility of reshaping (adding, removing) fields in the future while keeping the byte serialization structure compatible. First tuple entries of this collection discern internal fields, second tuple entries are Binary Serialization Standard compliant serializations of data.
Currently the "keys" (first tuple entries) of the fields
map are interpreted as:
- payload with key
0
: an instance ofTransactionArgs
- payload with key
1
: an instance ofTransactionTarget
- payload with key
2
: an instance ofTransactionEntryPoint
- payload with key
3
: an instance ofTransactionScheduling
TransactionArgs
TransactionArgs
(serialized using calltable scheme) consists of:
- in variant
Named
- variant discriminator of value
0
- RuntimeArgs with serialization index
1
- variant discriminator of value
- in variant
Bytesrepr
- variant discriminator of value
1
- Bytes with serialization index
1
- variant discriminator of value
TransactionTarget
TransactionTarget
(serialized using calltable scheme) consists of:
- in variant
Native
- variant discriminator of value
0
- variant discriminator of value
- in variant
Stored
- variant discriminator of value
1
- field
id
of type TransactionInvocationTarget with serialization index1
- field
runtime
of type TransactionRuntimeParams with serialization index2
- variant discriminator of value
- in variant
Session
- variant discriminator of value
2
- field
is_install_upgrade
of typebool
with serialization index1
- field
module_bytes
of typeBytes
with serialization index2
- field
runtime
of type TransactionRuntimeParams with serialization index2
- variant discriminator of value
TransactionInvocationTarget
TransactionInvocationTarget
(serialized using calltable scheme) consists of:
- in variant
ByHash
- variant discriminator of value
0
HashAddr
with serialization index1
- variant discriminator of value
- in variant
ByName
- variant discriminator of value
1
String
with serialization index1
- variant discriminator of value
- in variant
ByPackageHash
- in variant
ByPackageName
TransactionRuntimeParams
TransactionRuntimeParams
(serialized using calltable scheme) consists of:
- in variant
VmCasperV1
:- variant discriminator of value
0
- variant discriminator of value
- in variant
VmCasperV2
:- variant discriminator of value
1
- field
transferred_value
of typeu64
(8 bytes unsigned number) with serialization index1
- field
seed
of typeOption<[u8; 32]>
(option of 32 bytes Byte array) with serialization index2
- variant discriminator of value
TransactionEntryPoint
TransactionEntryPoint
(serialized using calltable scheme) consists of:
- in variant
Call
:- variant discriminator of value
0
- variant discriminator of value
- in variant
Custom
:- variant discriminator of value
1
String
with serialization index1
- variant discriminator of value
- in variant
Transfer
:- variant discriminator of value
2
- variant discriminator of value
- in variant
AddBid
:- variant discriminator of value
3
- variant discriminator of value
- in variant
WithdrawBid
:- variant discriminator of value
4
- variant discriminator of value
- in variant
Delegate
:- variant discriminator of value
5
- variant discriminator of value
- in variant
Undelegate
:- variant discriminator of value
6
- variant discriminator of value
- in variant
Redelegate
:- variant discriminator of value
7
- variant discriminator of value
- in variant
ActivateBid
:- variant discriminator of value
8
- variant discriminator of value
- in variant
ChangeBidPublicKey
- variant discriminator of value
9
- variant discriminator of value
- in variant
AddReservations
:- variant discriminator of value
10
- variant discriminator of value
- in variant
CancelReservations
:- variant discriminator of value
11
- variant discriminator of value
- in variant
Burn
:- variant discriminator of value
12
- variant discriminator of value
TransactionScheduling
TransactionScheduling
(serialized using calltable scheme) consists of:
- in variant
Standard
:- variant discriminator of value
0
- variant discriminator of value