Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/send-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,46 @@ const main = async () => {

main()
```
## Transaction result

As showed before, the result of sending a transaction can be captured on a variable or constant, allowing you to access its result and any errors that may occur. This can be specially interesting for testing the behavior of any events that were emitted during the execution of the transaction.

### Checking events

The `events` object array can be found inside the result object, following the previous example:

```
const [result, error, logs] = await shallPass(
sendTransaction("log-message", [], args)
)
console.log({result})
```
The console output will be:
```
{
blockId: '',
status: 4,
statusString: 'SEALED',
statusCode: 0,
errorMessage: '',
events: [ [Object] ]
}
```

And if we dig a little further on the events object:
```
console.log({result.events})
```
We will get the array containing the emitted events, that will look something like this:
```
[
{
type: 'eventType',
transactionId: 'txId',
transactionIndex: 1,
eventIndex: 0,
data: {}
}
]
```
Most times you will want to access the `data` object inside each emitted event to test that the info emitted matches what is expected.