Skip to content

Sending cross-chain requests

How to emit a CrossChainRequest by hand or from the load generator, which rules the requested call must obey, and how to read a failure.

You will learn / You need

You will learn: what each argument of bridge_source::request means, how the load generator sends the same request, the constraints on the call, and how to read a failed request. You need: the one-time setup finished, with bridge mode ready in the handler log.

The request call

Deploy first

The listener starts from the current chain tip, so events emitted while it is down are skipped.

This calls bridge_target::record(1u64, 42u64, b"hello") on chain 2:

iota client call --package <BRIDGE_SOURCE_PACKAGE> --module bridge_source --function request \
  --args <SOURCE_CONFIG_ID> 2 <BRIDGE_TARGET_PACKAGE> \
    '[98,114,105,100,103,101,95,116,97,114,103,101,116]' '[114,101,99,111,114,100]' \
    '[[1,0,0,0,0,0,0,0],[42,0,0,0,0,0,0,0],[5,104,101,108,108,111]]' '[]' \
  --gas-budget 20000000

The arguments are the source config, the target chain id, the target package, the module and function names as ASCII bytes, and the BCS-encoded call and type arguments. In the order of bridge_source::request (Move API):

Position Value in the example Meaning
1 <SOURCE_CONFIG_ID> The frozen SourceConfig from setup step 2
2 2 target_chain_id
3 <BRIDGE_TARGET_PACKAGE> target_package
4 [98,114,…] target_module, the ASCII bytes of bridge_target
5 [114,101,…] target_function, the ASCII bytes of record
6 [[1,0,0,0,0,0,0,0],[42,…],[5,104,…]] args: one BCS byte vector per call argument. 1u64, 42u64 and the vector b"hello" (length prefix 5, then the bytes)
7 [] type_args: none

request aborts when the module or function name is empty (codes 0 and 1, see abort codes).

Through the load generator

The load generator sends the same request through /api/SendPTB using agent/payloads/bridge_request.json. There, auth.address becomes the intent's source_sender, so it must be in the ACL. With thousands of agent addresses, authorise them in bulk with bridge_acl_add. The route and its payload grammar are described in HTTP API and PTB argument encoding.

Batching

The handler does not submit one transaction per event. It bundles up to BATCH_SIZE events into one destination transaction, with one signed intent and one call per event. An event that cannot be built is excluded and fails alone, but a revert or a submission failure fails every event in the batch. The gas consequences are in Gas pool sizing.

Constraints

  • The matched call takes only pure arguments. An object argument or a Result makes it non-matching. Other commands in the PTB are unconstrained.
  • Type arguments are BCS-encoded canonical type strings, not TypeTags.
  • Chain ids are labels you choose, and must agree in three places: the account's chain_id, the ACL entry's source_chain_id, and the SourceConfig.
  • Replay protection is off-chain only. The listener persists handled event ids in events_data/processed_events.json on the host (data/processed_events.json inside the container); there is no on-chain nonce.
  • One call can satisfy several intents: matching does not consume the call. For each intent the authenticator only needs some call that matches.
  • Account abstraction on IOTA is moving fast. The pinned iota-* crates are older than the networks' protocol version, and a new authenticator release could break this flow.

Errors

timed-out before finality could be reached (code 14) from the event handler is almost always failed authentication, usually a source_sender missing from the ACL. Other bridge_authenticator aborts:

Code Meaning
1 ESenderNotInAcl: the source sender has no ACL entry
2 EInvalidSignature: the signature does not match the stored key
3 ENoMatchingCall: no PTB call matches the intent
4 EWrongTargetChain: the intent targets another chain id

The authenticator checks in the order target chain (4), ACL (1), signature (2), PTB match (3), so the first code you see names the first check that failed. Codes 0 and 5 to 11 are in Move API and abort codes. Failures that never reach the chain are recorded in bridge_results.csv with a failure_stage (columns); see also Troubleshooting.

To check a live account, run this from testing_backend/:

cargo test --lib -- --ignored bridge_aa_prechecks --nocapture

Check it worked

  • The digest in the handler log shows status success, the BridgeAA address as sender and a bridge_target::Recorded event.
  • The matching row of bridge_results.csv has success true and an empty failure_stage.
  • A request from an address missing from the ACL is refused at the account, not on the source chain: request itself still succeeds and emits the event.

Next