Activities & Events
After executing a plan, you’ll want to track its progress. Legend provides two complementary mechanisms.Activities
Activities represent completed or in-progress on-chain operations. Each activity has:activity_type— What happened (e.g.,"quark_operation_executed")activity_status— Current state:"pending","confirmed", or"failed"activity_metadata— Details about the operations (amounts, assets, chains)
Activity lifecycle
Events
Events provide a real-time stream of changes to a sub-account. Use them for:- Webhooks-style monitoring — Long-poll for updates instead of repeatedly fetching activities
- Cursor-based pagination — Track where you left off with the
cursorvalue
Long-polling
Passpoll=true to the Events endpoint and the request will hang until new events arrive (up to ~30 seconds). This is more efficient than polling activities on a timer.
When to use which
| Use case | Recommended |
|---|---|
| Show transaction history | Activities |
| Wait for a specific transaction to confirm | Events (long-poll) |
| Build a real-time dashboard | Events (long-poll loop) |
| Debug a failed transaction | Activity (by ID) |