Annotation Type Transaction


@Target(METHOD)
@Retention(RUNTIME)
public @interface Transaction
Indicates that a method is a transaction method. The annotated method should execute the transaction, possibly modifying the blockchain state.

The method should be a public Service method.

Parameters

The annotated method shall have the following parameters (in this particular order):

  1. transaction arguments either as byte[] or as a protobuf message. Protobuf messages are deserialized using a #parseFrom(byte[]) method
  2. transaction execution context as ExecutionContext. It allows to access the information about this transaction and modify the blockchain state through the included database access object.

Exceptions

The annotated method might throw ExecutionException if the transaction cannot be executed normally and has to be rolled back. The transaction will be committed as failed (error kind SERVICE). The error code with the optional description will be saved in the storage.

If the annotated method throws any other exception, it is considered an unexpected error. The transaction will be committed as failed (error kind UNEXPECTED).

Exonum rolls back any changes made by a transaction that threw an exception. It also saves any error into the registry of call errors. The transaction clients can request the error information to know the reason of the failure.

See Also:
Exonum Transactions, Exonum Services
  • Required Element Summary

    Required Elements 
    Modifier and Type Required Element Description
    int value
    The transaction type identifier.
  • Element Details

    • value

      int value
      The transaction type identifier. Must be unique within the service.

      The transaction id is specified in the transaction messages.