Setting it up and sending events¶
Point the listener at a source module, name the call the handler should make, deploy, and emit an event.
You will learn / You need
You will learn: which variables static mode reads, how to emit an event the listener picks
up, and what to expect in the logs.
You need: a working setup (.env and keystore), the
deployment basics, the IOTA CLI, and a Move function to call on
the destination chain that the relayer key can call.
1. Choose the destination call¶
Static mode runs one call on every event. It needs a function already published on the destination
network. Any function works if the relayer key is allowed to call it and the arguments you give
match its parameters. The default target is counter::increment in a fixed package you probably have not
published: set your own.
2. Configure .env¶
Only these variables matter in static mode. Each links to its row in Configuration; everything else can stay as it is.
| Variable | Set it to |
|---|---|
BRIDGE_PROTOCOL_PHASES |
2. .env_sample ships 3, which is a startup error in static mode (BRIDGE_PROTOCOL_PHASES=3 requires EVENT_HANDLER_MODE=bridge). |
EVENT_HANDLER_MODE |
static. This is the default when unset, but .env_sample ships bridge, so change it. |
EVENT_HANDLER_TARGET |
<package_id>::<module>::<function> of the destination call. |
EVENT_HANDLER_ARGS_JSON |
The call's arguments as a JSON array, for example [["object","0x..."]]. Invalid JSON becomes an empty array, without a warning. |
EVENT_HANDLER_SIGNER |
The relayer address. It must be in the keystore and own gas coins on the destination network. |
EVENT_HANDLER_NETWORK |
devnet or testnet: where the destination call runs. |
EVENT_HANDLER_KEYSTORE_PATH |
The keystore file, if not the default. |
LOADTEST_GAS_BUDGET_BRIDGE |
Gas budget of one call. It must fit in one of the signer's coins. |
EVENT_HANDLER_GAS_COINS, EVENT_HANDLER_CONCURRENCY |
How many coins to read at startup and how many transactions run at once. |
EVENT_LISTENER_PACKAGE_ID |
The package that emits your trigger events. |
EVENT_LISTENER_MODULE |
The module that emits them. |
EVENT_LISTENER_RPC_URL, EVENT_HANDLER_URL |
Normally left alone. The first is the source chain's JSON-RPC endpoint the listener polls (default testnet); the second is where the listener posts events (default http://event_handler:5000/api/handle_event, the compose service). |
EVENT_LISTENER_EVENT_TYPE |
Optional. Only events whose type contains this string trigger a call. |
Arguments use the same JSON forms as /api/SendPTB; see PTB argument encoding.
Fund the relayer key
In static mode the relayer address pays the gas. Check that it owns coins on
EVENT_HANDLER_NETWORK before you deploy: the coin pool is read once, at startup.
Then deploy, as in Deployment: ./deploy.sh from
stealth_name_service/backend.
3. Emit a source event¶
The listener picks up every event emitted by EVENT_LISTENER_PACKAGE_ID::EVENT_LISTENER_MODULE,
narrowed by EVENT_LISTENER_EVENT_TYPE when it is set. The repository's source package,
bridge_source, emits CrossChainRequest from bridge_source::request, so the sample values are
module bridge_source and type CrossChainRequest. Any other module that emits events works too:
static mode never reads them.
Deploy before you send
The listener starts from the chain tip. An event emitted before it is running, or while it is restarting, is never delivered.
Both routes below call bridge_source::request. You need bridge_source published on the source
chain and a SourceConfig object; steps 1 and 2 of "One-time setup" in
Cross-chain transactions show how. Skip the BridgeAA steps: static mode does
not use one. The event's contents are irrelevant here, so the arguments only have to satisfy
request.
Use the iota client call … --function request command from "Sending a request" on the
Track C setup page. It makes the source-chain account that signs it the
event's sender; static mode does not check that sender.
The load generator's sample payload, stealth_name_service/backend/agent/payloads/bridge_request.json,
is one call to bridge_source::request on testnet. Replace the package id, the SourceConfig
object id and auth.address with yours, then send it as in
Your first PTB:
curl -s -X POST http://localhost:5000/api/SendPTB \
-H 'Content-Type: application/json' \
-d @stealth_name_service/backend/agent/payloads/bridge_request.json
The auth.address pays for this source transaction. It must be a keystore address with coins on
the payload's network.
Check it worked¶
- The listener log says
Event type filter: …andWatching <package>::<module>at start, thenForwarded event <digest>:<seq> -> status 202for each event. - The handler log says
listening on http://0.0.0.0:5000/api/handle_eventandbatch confirmedwith adigestfield. Details are on Verifying and measuring.
If events do not arrive, check the filters first: a wrong package, module or event type is silent.
Next¶
- Verifying and measuring: confirm the destination transaction and read the CSV.