Skip to content

Pushing Transactions

A transaction refers to a set of actions bundled together and submitted to the blockchain as a single atomic operation. It represents a unit of work or a state change that can be executed on the Ultra network. Transactions are fundamental to interacting with smart contracts and updating the blockchain state.

Push a transaction with cleos

Open your terminal or command prompt.

The transaction command has the following structure:

sh
cleos push transaction '
  {"actions":
    [
      {
        "account":"<contract_account>",
        "name":"<action_name>",
        "authorization":
          [
            {
              "actor":"<actor_account>",
              "permission":"<actor_permission>"
            }
          ],
        "data":<data_as_json_string>}
      ]
    }'
  • <contract_account>: The account associated with the contract where the action is defined.
  • <action_name>: The name of the action you want to invoke.
  • <actor_account>: The account that authorizes and signs the transaction.
  • <actor_permission>: The permission level of the actor account (e.g., "active").
  • <data_as_json_string>: The parameters or data for the action in JSON format. Ensure that you properly format the data according to the action's requirements.

Replace the placeholders <contract_account>, <action_name>, <actor_account>, <actor_permission>, and <data_as_json_string> with the actual values specific to your contract, action, and transaction data.

If the transaction is successful, you will receive a transaction ID as output. You can use this ID to verify the transaction's status on a block explorer.

Transaction Format

On Ultra, transactions are formatted using JSON and consist of the following components:

Signatures are the cryptographic proof that an authorized account has approved and authorized the transaction. Signatures are generated using the private key corresponding to the account's public key.

Transactions can be optionally compressed using the zlib compression algorithm to reduce their size when transmitted over the network.

Packed Transaction: The packed transaction is the core component of the transaction format. It includes the following sub-components:

  • expiration: The expiration time of the transaction, represented as a timestamp. The transaction must be included in a block before this time to be considered valid.
  • ref_block_num and ref_block_prefix: These values refer to the block number and block prefix of a previous block. They are used for generating a unique identifier for the transaction and for ensuring that the transaction cannot be replayed on a different fork of the blockchain.
  • max_net_usage_words and max_cpu_usage_ms: These values represent the maximum allowed network and CPU usage for the transaction. The transaction's actions must consume resources within these limits to be accepted by the network.
  • delay_sec: An optional delay (in seconds) for scheduling the execution of the transaction.
  • context_free_actions: These are actions that do not require any context from the blockchain state. They can be executed in parallel and do not affect the transaction's authorization or signing.
  • actions: The main actions that define the intended operations to be performed on the blockchain. Each action includes the account, action name, authorization, and associated data.

Once the transaction is signed and ready for broadcasting, it is assigned a unique transaction ID. The ID is generated by hashing the packed transaction using the SHA-256 algorithm.

The use of JSON and cryptographic signatures ensures the integrity and authenticity of the transactions while facilitating interoperability with different tools and libraries.