Just like in solidity there is event that you can trigger when transaction finish for example? can I do that in ICP rust?
What is your use case?
many
When transaction finish send notifications
When someone send you new tokens (Our own offchain tokens) you get notified
plug wallet has something like it, I know because when you receive tokens you’ll get a notification on your phone (without having the app open). Not sure if its on chain though.
We’ve built an extensive event system that is in alpha:
We currently do not have any rust components built, but the system follows ICRC-72 and we’re looking for community members that would be interested in building the rust equivalent of the motoko components we do have.
With the current tools we can build a watcher that will broadcast any detected events to any number of listeners. If your canister is rust and you just want to listen, you really just need to implement the subscriber side of things which includes registration(an IC call), listening for being assigned a broadcaster(just implement the icrc72_hadle_event endpoint and parse the event type) and then you can validate incoming calls from valid broadcasters and see when your event namespace comes across. At the end of the call you can send cycles back to the broadcaster to pay for the notification.
I believe there are good reasons to also investigate and standardise a low level event log format. Subscribing, broadcasting, orchestrating, etc would be out of scope for that standard. A canister simply would publish all their state transitions in an open log, in a format that can be parsed by third parties.
The log would contain complete state transitions. That is, a canister that is upgraded should be able to rebuild its state based on that log.
I believe the BTC minter uses this pattern already. And Odin.fun. And a bridge project I explored over Christmas.
The benefits with such a log format are many:
- Being able to rebuild state from log
- Easy data type migrations when rebuilding state
- Log can be subscribed to (polled) by external indexers, both belonging to the app in question, and to external services such as block explorers etc
- Increases transparency, allows anyone to independenty verify that the the current state is correct, by replaying the event log themselves
I’d love your eyes on ICRC-105 and 133 as they are intended to do just that: ICRC-105 and it's seven cousins
Oh, interesting, will have a look!