Skip to main content

How to listen for transactions receipts

Use the Orchestrate SDK to listen for successful transactions (mined) on any Blockchain network. The process of sending transactions on Ethereum is asynchronous, meaning that Orchestrate notifies Kafka once the transaction receipt is ready.

Orchestrate allows you to:

Get a transaction receipt



  1. Instantiate a consumer connected to Kafka: const consumer = new Consumer(['localhost:9092']).
  2. Execute the connect() function of the consumer.
  3. Register an event listener on the consumer (see example below).
  4. Execute the consume() function on the consumer.

For each successfully received transaction receipt, we recommend executing the commit() function to notify Kafka the message has been successfully processed and that it should not be read again even if the listener restarts.

await consumer.connect();

// Register the event listener before calling consume
consumer.on(EventType.Response, async (message: ResponseMessage) => {
const { offset, topic, value } = message.content();

console.log("Message received !", {
jobUUID: value.jobUUID,
chain: value.chain,

if (value.errors && value.errors.length !== 0) {
console.log("Transaction failed!", {
errors: value.errors,
txContext: value.txContext,
} else {
console.log("Receipt:", value.receipt);

// We commit every message
await message.commit();

await consumer.consume();

Transaction failures

When Orchestrate sends a transaction, it goes through two processes. During the first process, Orchestrate builds and checks the transaction and routes it to the right chain and node. During the second process, the target node handles the transaction and adds it to the blockchain.

These two processes are executed one after the other and both processes trigger events. The first event indicates the success of the first phase, between orchestrate and the blockchain, and the second event indicates the success on the blockchain itself.

If the transaction fails during the first process, the console log displays Transaction failed! and does not generate a receipt.

If the transaction connects to the blockchain, it attempts to complete the second process. If the second phase is successful, the transaction goes through and generates the transaction receipt. The status field in the transaction receipt displays true.

If the second phase fails, the transaction does not go through, but still generates a receipt. In this case, the status field in the transaction receipt displays false. Refer to the revert reason to determine why the contract might have failed.

Revert reason

The revert reason displays in the transaction receipt if an error occurs during execution of a smart contract. Smart contracts must use the revert or require features to be able to return a revert reason.

For example, the ERC20 token smart contract can return a revert reason when not enough tokens are available at the source address when transferring tokens. The message "ERC20: transfer amount exceeds allowance" is then returned to the user in the transaction receipt.


  • The revert reason must be configured on nodes. For instance on Hyperledger Besu, the --revert-reason-enabled option must be set.
  • The smart contract to which transactions are sent must implement a revert reason on failure.

Read the revert reason

Orchestrate helps by decoding the revert reason and displays the clear message in the output. Simply retrieve the revertReason field of the receipt.

Decoded revert reason

Decoded revert reason in transaction receipt

The revertReason property in the transaction receipt JSON output has the decoded ERC20: transfer amount exceeds balance string value instead of the encoded raw value.