Skip to content

Commit

Permalink
New translations triggers.mdx (Urdu (Pakistan))
Browse files Browse the repository at this point in the history
  • Loading branch information
benface committed Jan 27, 2025
1 parent 90fecce commit 3f3cf6d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions website/pages/ur/sps/triggers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
title: Substreams Triggers
---

Custom triggers allow you to send data directly into your subgraph mappings file and entities (similar to tables and fields), enabling full use of the GraphQL layer. By importing the Protobuf definitions emitted by your Substreams module, you can receive and process this data within your subgraph’s handler, ensuring efficient and streamlined data management within the subgraph framework.
Use Custom Triggers and enable the full use GraphQL.

> Note: If you haven’t already, visit one of the How-To Guides found [here](./introduction) to scaffold your first project in the Development Container.
## جائزہ

Custom Triggers allow you to send data directly into your subgraph mappings file and entities, which are similar to tables and fields. This enables you to fully use the GraphQL layer.

By importing the Protobuf definitions emitted by your Substreams module, you can receive and process this data in your subgraph's handler. This ensures efficient and streamlined data management within the subgraph framework.

### Defining `handleTransactions`

The following code demonstrates how to define a `handleTransactions` function in a subgraph handler. This function receives raw Substreams bytes as a parameter and decodes them into a `Transactions` object. For each transaction, a new subgraph entity is created.

```tsx
export function handleTransactions(bytes: Uint8Array): void {
let transactions = assembly.eth.transaction.v1.Transactions.decode(bytes.buffer).trasanctions // 1.
let transactions = assembly.eth.transaction.v1.Transactions.decode(bytes.buffer).transactions // 1.
if (transactions.length == 0) {
log.info('No transactions found', [])
return
Expand All @@ -28,10 +34,14 @@ export function handleTransactions(bytes: Uint8Array): void {
}
```

Here's what youre seeing in the `mappings.ts` file:
Here's what you're seeing in the `mappings.ts` file:

1. The bytes containing Substreams data are decoded into the generated `Transactions` object, this object is used like any other AssemblyScript object
2. Looping over the transactions
3. Create a new subgraph entity for every transaction

To go through a detailed example of a trigger-based subgraph, [click here](./triggers-example).
To go through a detailed example of a trigger-based subgraph, [check out the tutorial](/sps/tutorial/).

### اضافی وسائل

To scaffold your first project in the Development Container, check out one of the [How-To Guide](/substreams/developing/devcontainer/).

0 comments on commit 3f3cf6d

Please sign in to comment.