Skip to content

Transaction

This is the specification for transactions, which includes signed transactions from users and executable events, which are spawned by the blockchain.

You can learn more about how interactions work on the blockchain here.

Signed Transaction

A signed transaction is an instruction from a user containing information, which is used to change the state of the blockchain. After constructing a binary signed transaction it can be delivered to any node producing blocks in the private network through their REST API.

The following is the specification of the binary format of signed transactions.

The easiest way of creating a binary signed transaction is by using one of the available client libraries. This specification can help you if you want to make your own implementation, for instance if you are targeting another programming language.

SignedTransaction

::= {

signature: Signature transaction: Transaction

}

Signature

::= {

recoveryId: 0xnn

valueR: 0xnn×32

(big-endian)

valueS: 0xnn×32

(big-endian)

}

The Signature includes:

  • A recovery id between 0 and 3 used to recover the public key when verifying the signature
  • The r value of the ECDSA signature
  • The s value of the ECDSA signature
Transaction

::= {

nonce: 0xnn×8

(big-endian)

validToTime: 0xnn×8

(big-endian)

gasCost: 0xnn×8

(big-endian)

address: Address

rpc: Rpc

}

Rpc

::= len:0xnn×4 payload:0xnn×len

(len is big-endian)

The Transaction includes:

  • The signer's nonce
  • A unix time that used to defined how long the transaction is valid to be executed.
  • The amount of gas allocated to executing the transaction, for a private deployment no gas is needed, so the amount should be 0.
  • The address of the smart contract that is the target of the transaction.
  • The Rpc payload of the transaction. See Smart Contract Binary Formats for a way to build the rpc payload.

Creating the signature

The signature is an ECDSA signature, using secp256k1 as the curve, on a sha256 hash of the transaction and the chain ID of the blockchain.

ToBeHashed

::= transaction:Transaction chainId:ChainId

The chain id is a unique identifier for the blockchain. For example, the chain id for the private deployment is Private Blockchain.

Executable Event

An executable event is spawned by the blockchain, and not by a user. It can be created from other events or when the blockchain receives a signed transaction. The executable event contains the information about which action to perform to a smart contract.

The following is the specification of the binary format of executable events.

ExecutableEvent

::= {

originShard: Option<String> transaction: EventTransaction

}

The originShard is an Option<String>, the originating shard of the event.

EventTransaction

::= {

originatingTransaction: Hash inner: InnerEvent shardRoute: ShardRoute committeeId: Long governanceVersion: Long

height: Byte

(unsigned)

returnEnvelope: Option<ReturnEnvelope>

}

The transaction, EventTransaction, includes:

  • The originating transaction: the SignedTransaction initiating the tree of events that this event is a part of.
  • The event type, InnerEvent.
  • The ShardRoute describes which shard the event should be executed on.
  • The id of the committee that produced the block where the event was spawned.
  • The governance version when this event was produced.
  • The height of the event tree, which is increased for each event spawned after a signed transaction.
  • If there is a callback registered to the event, the result of the event is returned in a ReturnEnvelope.

Event Types

The InnerEvent of an EventTransaction is divided into four types of events: InnerTransaction, CallbackToContract, InnerSystemEvent and SyncEvent.

Inner Transaction

A transaction is sent by the user or the contract, meaning that it represents the actions the user can activate. Transactions can either deploy contracts or interact with them. Each transaction also carries an associated sender and an associated cost.

InnerTransaction

::= {

from: Address cost: Long transaction: Transaction

}

CreateContractTransaction

::= {

address: Address binderJar: DynamicBytes contractJar: DynamicBytes abi: DynamicBytes rpc: DynamicBytes

}

Callback to Contract

Callback transactions call the callback methods in contracts.

CallbackToContract

::= {

address: Address callbackIdentifier: Hash from: Address cost: Long callbackRpc: DynamicBytes

}

Inner System Event

System events can manipulate the system state of the blockchain. These are primarily sent by system/governance contracts.

InnerSystemEvent

::= {

systemEventType: SystemEventType

}

CreateAccountEvent

::= {

toCreate: Address

}

CheckExistenceEvent

::= {

contractOrAccountAddress: Address

}

SetFeatureEvent

::= {

key: String value: Option<String>

}

ChainPluginType

::=

0x00 => Account

| 0x01 => Consensus

| 0x02 => Routing

| 0x03 => SharedObjectStore

CallbackEvent

::= {

returnEnvelope: ReturnEnvelope completedTransaction: Hash success: Boolean returnValue: DynamicBytes

}

CreateShardEvent

::= {

shardId: String

}

RemoveShardEvent

::= {

shardId: String

}

UpgradeSystemContractEvent

::= {

contractAddress: Address binderJar: DynamicBytes contractJar: DynamicBytes abi: DynamicBytes rpc: DynamicBytes

}

RemoveContract

::= {

contractAddress: Address

}

Sync Event

A sync event is used for moving information from one shard to another when changing the shard configuration. That is, when adding or removing shards or when changing routing logic.

SyncEvent

::= {

accounts: List<AccountTransfer> contracts: List<ContractTransfer> stateStorage: List<DynamicBytes>

}

AccountTransfer

::= {

address: Address accountStateHash: Hash pluginStateHash: Hash

}

ContractTransfer

::= {

address: Address ContractStateHash: Hash pluginStateHash: Hash

}

ShardRoute

::= {

targetShard: Option<String> nonce: Long

}

Common Types

Address

::= addressType:AddressType identifier:0xnn×20

(identifier is big-endian)

AddressType

::=

0x00 => Account

| 0x01 => System

| 0x02 => Public

| 0x03 => Zk

| 0x04 => Gov

Boolean

::= b:0xnn

(false if b==0, true otherwise)

Byte

::= 0xnn

DynamicBytes

::= len:0xnn×4 payload:0xnn×len

(big-endian)

Hash

::= 0xnn×32

(big-endian)

List

::= len:0xnn×4 elems:T×len

(len is big-endian)

Long

::= 0xnn×8

(big-endian)

Option<T>

::=

0x00 => None

 

| b:0xnn t:T => Some(t)

(b != 0)

ReturnEnvelope

::= Address

String

::= len:0xnn×4 uft8:0xnn×len

(big-endian)

Partisia All Rights Reserved © 2023