Skip to content

Commit

Permalink
Merge pull request #700 from multiversx/log-events
Browse files Browse the repository at this point in the history
Log events
  • Loading branch information
miiu96 committed Sep 20, 2023
2 parents 68960b6 + d97a341 commit 0fa6715
Show file tree
Hide file tree
Showing 7 changed files with 462 additions and 11 deletions.
5 changes: 5 additions & 0 deletions docs/developers/event-logs/contract-call-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
id: contract-call-events
title: Smart Contract Call Events
---

5 changes: 5 additions & 0 deletions docs/developers/event-logs/contract-deploy-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
id: contract-deploy-events
title: Smart Contract Deploy Events
---

231 changes: 231 additions & 0 deletions docs/developers/event-logs/esdt-events.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
---
id: esdt-events
title: ESDT Operations Events
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


ESDT Operations Events are generated in response to interactions with an ESDT token.
These events help keep track of actions like creating new tokens, transferring tokens between addresses, burning tokens, etc.


### Fungible token transfer

The `ESDTTransfer` event is emitted when a fungible token undergoes a transfer operation via the `ESDTTransfer` built-in function.
<Tabs
defaultValue="Structure"
values={[
{label: 'Structure', value: 'Structure'},
{label: 'Example', value: 'Example'},
]}
>
<TabItem value="Structure">

| Field | Value |
|------------|------------------------------------------------------------------------------------------------------------------------|
| identifier | ESDTTransfer |
| address | the sender of the token |
| topics | `topics[0]` - token identifier base64 encoded <br/>`topics[1]` - empty <br/> `topics[2]` - value bytes base64 encoded <br/> `topics[3]` - receiver address address bytes base64 encoded |
| data | empty |

</TabItem>
<TabItem value="Example">

```json
{
"identifier": "ESDTTransfer",
"address": "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u",
"topics": [
"VVRLLWI5NzQ4MA==",
"",
"AzsuPJ/QgDzoAAAA",
"0+diI4/UjUcgbmchGtML1QwheMY68dnsww9vhRPJUWg="
],
"data": null
}
```

</TabItem>
</Tabs>


### Semi-fungible, non-fungible or meta-esdt token creation

The `ESDTNFTCreate` event is generated when a new token is created using the built-in function `ESDTNFTCreate`.

<Tabs
defaultValue="Structure"
values={[
{label: 'Structure', value: 'Structure'},
{label: 'Example', value: 'Example'},
]}
>
<TabItem value="Structure">

| Field | Value |
|------------|------------------------------------------------------------------------------------------------------------------------------|
| identifier | ESDTNFTCreate |
| address | the creator of the token |
| topics | `topics[0]` - token identifier base64 encoded <br/>`topics[1]` - token nonce bytes base64 encoded <br/> `topics[2]` - value bytes base64 encoded <br/> `topics[3]` - ESDigitalToken structure marshalled with gogo proto serializer |
| data | empty |

</TabItem>
<TabItem value="Example">

```json
{
"identifier": "ESDTNFTCreate",
"address": "erd1qqqqqqqqqqqqqpgq0tajepcazernwt74820t8ef7t28vjfgukp2sw239f3",
"topics": [
"TFlaLTBmM2MxMQ==",
"AQ==",
"AQ==",
"CAESAgABIvwBCAESBWx5cmFaGiAJ7NX5x1oDr20FnI7bUkyNRhecngUl6Jlvjjzlcu0BuSD0Ayo7YmFma3JlaWNqbXVwMndna21qaXR0a2dpbzZydXlpb3h6cHpraHZ6b3Jvand5eHU0Y2RiNnQycHRhaGkyQmlwZnM6Ly9iYWZrcmVpY2ptdXAyd2drbWppdHRrZ2lvNnJ1eWlveHpwemtodnpvcm9qd3l4dTRjZGI2dDJwdGFoaTpLbWV0YWRhdGE6YmFma3JlaWNqbXVwMndna21qaXR0a2dpbzZydXlpb3h6cHpraHZ6b3Jvand5eHU0Y2RiNnQycHRhaGkvbHlyYVp9"
],
"data": null
}
```

</TabItem>
</Tabs>

### Semi-fungible, non-fungible or meta-esdt token transfer

The `ESDTNFTTransfer` event is generated when a token, which can be semi-fungible, non-fungible, or meta-esdt,
is moved through the `ESDTNFTTransfer` built-in function.

<Tabs
defaultValue="Structure"
values={[
{label: 'Structure', value: 'Structure'},
{label: 'Example', value: 'Example'},
]}
>
<TabItem value="Structure">

| Field | Value |
|------------|------------------------------------------------------------------------------------------------------------------------------|
| identifier | ESDTNFTTransfer |
| address | the sender of the token |
| topics | `topics[0]` - token identifier base64 encoded <br/>`topics[1]` - token nonce bytes base64 encoded <br/> `topics[2]` - value bytes base64 encoded <br/> `topics[3]` - receiver address bytes base64 encoded |
| data | empty |

</TabItem>
<TabItem value="Example">

```json
{
"identifier": "ESDTNFTTransfer",
"address": "erd1qqqqqqqqqqqqqpgq0tajepcazernwt74820t8ef7t28vjfgukp2sw239f3",
"topics": [
"WE1FWC1mZGEzNTU=",
"Aw==",
"LUrGxb4/2VjTAA==",
"0+diI4/UjUcgbmchGtML1QwheMY68dnsww9vhRPJUWg="
],
"data": null
}
```

</TabItem>
</Tabs>


### Multi token transfer

The `MultiESDTNFTTransfer` event is generated when one or multiple tokens are transferred using the built-in
function `MultiESDTNFTTransfer`.


<Tabs
defaultValue="Structure"
values={[
{label: 'Structure', value: 'Structure'},
{label: 'Example', value: 'Example'},
]}
>
<TabItem value="Structure">

| Field | Value |
|------------|---------------------------------------------------------------------------------------------------------------------------------|
| identifier | MultiESDTNFTTransfer |
| address | the sender of the token |
| topics | `topics[0]` - token identifier <br/>`topics[1]` - token nonce base64 encoded (can be empty in case of fungible token) <br/> `topics[2]` - value bytes base64 encoded <br/> `topics[3]` - receiver address bytes base64 encoded |
| data | empty |

</TabItem>
<TabItem value="Example">

```json
{
"identifier": "MultiESDTNFTTransfer",
"address": "erd1qqqqqqqqqqqqqpgq0tajepcazernwt74820t8ef7t28vjfgukp2sw239f3",
"topics": [
"WE1FWC1mZGEzNTU=",
"Aw==",
"LUrGxb4/2VjTAA==",
"0+diI4/UjUcgbmchGtML1QwheMY68dnsww9vhRPJUWg="
],
"data": null
}
```

</TabItem>
</Tabs>

:::note
For a multi-token transfer operation, multiple `MultiESDTNFTTransfer` events will be generated, one for each token being transferred.
:::

:::important Important
Starting from release `rc/v1.6.0`, the `MultiESDTNFTTransfer` will be changed when the flag `ScToScLogEventEnableEpoch` will be enabled.

Instead of generating multiple events with the same identifier, only one event will be generated for the entire multi-token transfer operation.
The event will follow the new format outlined below:

<Tabs
defaultValue="Structure"
values={[
{label: 'Structure', value: 'Structure'},
{label: 'Example', value: 'Example'},
]}
>
<TabItem value="Structure">

| Field | Value |
|------------|---------------------------------------------------------------------------------------|
| identifier | MultiESDTNFTTransfer |
| address | the sender of the token |
| topics | `PAIRS OF` <br/> < <br/>`topics[i]` - token identifier <br/>`topics[i+1]` - token nonce base64 encoded (can be empty in case of fungible token)<br/> `topics[i+2]` - value bytes base64 <br/>> <br/> `topics[n-1]` - receiver address |
| data | empty |

</TabItem>
<TabItem value="Example">

```json
{
"identifier": "MultiESDTNFTTransfer",
"address": "erd1j467tvyyr2dtxdz3lsgqaeez5umjsdn8fajexqlu7eum5wx2u0aqkca23a",
"topics": [
"MzlINk8tNDc5NmI4",
"Aw==",
"AQ==",
"UFFTMFItZDlmOTlk",
"",
"AQ==",
"StPRLp5kwnctf4If2CUhKr6Vux8WN3k3i5chL/y93UQ="
],
"data": null
}
```

</TabItem>
</Tabs>


:::



Loading

0 comments on commit 0fa6715

Please sign in to comment.