> For the complete documentation index, see [llms.txt](https://docs.ternoa.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ternoa.network/build-1/javascript/ternoa-js-library-utilities/retrieve-chain-events.md).

# Retrieve chain events

Each transaction emits events. At least`system.ExtrinsicSuccess` or `system.ExtrinsicFailed` event will be returned for each transaction. These provide the overall execution result for the transaction, i.e. execution has succeeded or failed.

{% hint style="info" %}
If you are not familiar with the process of creating a transaction on the Ternoa chain, we highly suggest first reading the Getting Started section of the documentation with a focus on the Ternoa-js [Blockchain Events](/getting-started/javascript-sdk/ternoa-js-library/blockchain-events.md) section and the [Workflow](/getting-started/javascript-sdk/ternoa-js-library/workflow.md).\
\
Learn more about Events in the [Polkadot's documentation. ](https://polkadot.js.org/docs/api/start/api.tx.subs#transaction-events)
{% endhint %}

One of the main advantages of using the Ternoa-js SDK is that it handles and formats directly the transaction response for us.&#x20;

> Find the full events list [here](/getting-started/javascript-sdk/ternoa-js-library/blockchain-events.md#the-events-below-are-the-events-handled-in-the-ternoa-sdk-sorted-by-categories).&#x20;

### Methods

Several methods are offered from the generic class `BlockchainEvents` issued in each transaction response, to retrieve the specific events we can look for:&#x20;

* `findEvent`: to retrieve one specific kind of event.
* `findEvents`: to retrieve several kinds of events.
* `findEventOrThrow`: to retrieve a specific kind of event or throw an error.

> Code available in the SDK repository [here](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/events.ts#L1846).&#x20;

### Retrieving events using the `BlockchainEvents` class

Whether you are using the [automated or custom](/getting-started/javascript-sdk/ternoa-js-library/workflow.md#lets-create) way to create a transaction, it should be submitted using the `submitTxBlocking()` function. The response will include the following objects:&#x20;

```typescript
blockInfo,
events,
txHash,
```

The events object is the one containing all the transaction events list. \
\
Look at the code snippet in the [Sign a transaction with Polkadot{.js} extension](/build-1/javascript/ternoa-js-library-utilities/sign-a-transaction-with-polkadot-.js-extension-in-a-browser-environment.md).\
\
You can see that the `submitTxBlocking()`is destructured to only get the events list on which the *findEventOrThrow* method is executed. It expects the name of the event for argument. \
Retrieve the complete events list [here](/getting-started/javascript-sdk/ternoa-js-library/blockchain-events.md#the-events-below-are-the-events-handled-in-the-ternoa-sdk-sorted-by-categories).

```typescript


export const createAndSignNFT = async (
 ...
) => {
  try {
    ...
    //5.1 - Submit the signed transaction
    const { events } = await submitTxBlocking(
      signedTx,
      WaitUntil.BlockInclusion
    );
    //5.2 - Return the filtered NFTCreatedEvent
    return events.findEventOrThrow(NFTCreatedEvent);
  } catch (error) {
    console.log(error);
  }
};
```
