Skip to content

add README Event #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ If you love this library and want to support its development you can donate any
- [Cells](#Cells)
- [Create](#Cells)
- [Parse](#Cells)
- [Event](#Event)
- [TLB Loader/Serializer](#TLB-Loader)
- [BoC](#BoC)
- [Proof creation](#Proofs)
Expand Down Expand Up @@ -406,6 +407,35 @@ There are 2 types of methods `Must` and regular. The difference is that in case
but regular will just return error, so use `Must` only when you are sure that your data fits max cell size and other conditions

To debug cells you can use `Dump()` and `DumpBits()` methods of cell, they will return string with beautifully formatted cells and their refs tree

##### Event

Event message type produced by `emit` is ExternalOut, so you need to listen out messages of desired contract.
```golang
go api.SubscribeOnTransactions(context.Background(), yourContractAddress, lastProcessedLT, transactions)

for tx := range transactions {
outs, err := tx.IO.Out.ToSlice()
if err != nil {
return err
}

for _, out := range outs {
if out.MsgType == tlb.MsgTypeExternalOut {
println("Event happened")
msg := out.AsExternalOut()
body := msg.Body.BeginParse()
opCode = body.MustLoadUInt(32) // Operation Code
id := body.MustLoadBigUInt(256) // Event field
addr := body.MustLoadAddr() // Event field
str := body.MustLoadStringSnake() // Event field
}
}
}
```

btw: `string snake` uses all remaining space of cell to store/load, so it must be the last field of cell.

##### BoC

Sometimes it is needed to import or export cell, for example to transfer over the network, for this, Bag of Cells serialization format is exists.
Expand Down