Skip to content

One-time bridge setup

A cross-chain transaction is a Move call requested on one chain and executed on another by an abstracted account, the BridgeAA, which never holds a private key. This page publishes the packages, creates the account, funds it and starts the relayer.

You will learn / You need

You will learn: the five setup steps, what the event handler checks before it accepts traffic, and how to send a first request. You need: a working setup (.env and keystore), the deployment basics, the IOTA CLI, gas on both chains, and the ideas in Relayers and cross-chain calls and Account abstraction and BridgeAA.

The relayer signs a CrossChainIntent. The account's authenticator checks that signature against its ACL, and checks that the submitted PTB really contains the described call.

Package Chain Role
bridge_source Source request() emits a CrossChainRequest event describing the call
bridge_abstract_account Destination The BridgeAA account and its bridge_authenticator
bridge_target Destination record(), a landing function for tests

One-time setup

flowchart LR
    P["1. Publish<br/>three packages"] --> C["2. create_config<br/>on the source chain"]
    C --> A["3. bridge_aa_init<br/>creates the BridgeAA"]
    A --> F["4. Fund the account<br/>with gas coins"]
    F --> D["5. ./deploy.sh<br/>wait for bridge mode ready"]

Work through the steps in order. Each row of the checklist says what you must hold before the next step.

Step Done when you have
1. Publish Three packageId values: bridge_source, bridge_target, bridge_abstract_account
2. Source config The object id of the SourceConfig
3. Create the account BRIDGE_AA_ACCOUNT_ID and the other lines bridge_aa_init printed, copied into .env
3b. Point .env at your deployment EVENT_LISTENER_PACKAGE_ID, EVENT_LISTENER_MODULE, EVENT_LISTENER_EVENT_TYPE, BRIDGE_TARGET_PACKAGE and BRIDGE_PROTOCOL_PHASES set to your own values
4. Fund the account Many equal gas coins owned by the BridgeAA, not by the relayer
5. Deploy bridge mode ready in the event handler log
  1. Publish the packages: bridge_source on the source chain, bridge_target and bridge_abstract_account on the destination chain. Take each packageId from the published entry of objectChanges, not the digest printed at the top.

    cd stealth_name_service/Move/bridge_source && iota client publish --gas-budget 200000000
    
  2. Create the source config. Publishing does not create it. The argument is the source chain id; keep the created object id, because every request call takes it.

    iota client call --package <BRIDGE_SOURCE_PACKAGE> --module bridge_source \
      --function create_config --args 1 --gas-budget 10000000
    
  3. Create the account. It prints the values to copy into .env. The variables are described in Bridge account; the tool itself in bridge_aa_init.

    cd stealth_name_service/backend/testing_backend
    EVENT_HANDLER_KEYSTORE_PATH=./iota.keystore BRIDGE_AA_PACKAGE_ID=<BRIDGE_AA_PACKAGE> \
    BRIDGE_SOURCE_CHAIN_ID=1 BRIDGE_TARGET_CHAIN_ID=2 \
    BRIDGE_ACL_SOURCE_SENDERS=<ADDRESS_THAT_CALLS_REQUEST> \
    EVENT_HANDLER_SIGNER=<RELAYER_ADDRESS> EVENT_HANDLER_NETWORK=devnet \
    cargo run --bin bridge_aa_init
    

    The relayer is always seeded as the bootstrap ACL entry, because create rejects an empty ACL. List every other address that will call request in BRIDGE_ACL_SOURCE_SENDERS; to add more later, see Managing the ACL. The relayer key must be ed25519 or secp256k1: the account cannot verify a secp256r1 signature, and the handler refuses such a key at startup.

    3b. Point the rest of .env at your deployment. bridge_aa_init prints only the EVENT_HANDLER_MODE, BRIDGE_AA_*, chain id and ACL lines. .env_sample ships the author's deployed ids, so a listener left as it is watches someone else's package, and it fails silently (a wrong filter is silent). Set these yourself:

    • EVENT_LISTENER_PACKAGE_ID=<bridge_source package>
    • EVENT_LISTENER_MODULE=bridge_source
    • EVENT_LISTENER_EVENT_TYPE=CrossChainRequest
    • BRIDGE_TARGET_PACKAGE=<bridge_target package> (read by bridge_acl_add and bridge_aa_coins)
    • Either BRIDGE_PROTOCOL_PHASES=2, or BRIDGE_PROTOCOL_PHASES=3 with BRIDGE_SOURCE_CONFIG_ID=<the object id from step 2>. In 3-phase mode the acknowledgement goes to that SourceConfig, so the sample's value would acknowledge on the author's config.
  4. Fund the account with gas coins. The BridgeAA is the sender of every bridged transaction, so the coins must belong to it, not to the relayer. Send it many equal coins with iota client pay-iota, or re-split its balance with bridge_aa_coins. How many, and how large, is the subject of Gas pool sizing.

  5. Deploy with ./deploy.sh and wait for bridge mode ready in the event handler log. The handler checks the account's chain id and the relayer's ACL entry at startup, and refuses to run if either is wrong.

Startup prechecks

Each check below turns what would be a Move abort on every request, after gas is spent, into one error at startup. The handler exits with the message in the second column. Messages are shortened; the code quotes more detail (build_bridge_config() in stealth_name_service/backend/testing_backend/src/bin/event_handler.rs).

Message starts with Meaning and fix
BRIDGE_AA_ACCOUNT_ID must be set when EVENT_HANDLER_MODE=bridge One of BRIDGE_AA_ACCOUNT_ID, BRIDGE_AA_PACKAGE_ID, BRIDGE_SOURCE_CHAIN_ID or BRIDGE_TARGET_CHAIN_ID is missing; the message names the one. An invalid value gives is not a valid object id or is not a u64.
EVENT_HANDLER_SIGNER (or SENDER_ADDRESS) must name the relayer key No relayer address is set. It must be the key registered in the ACL.
Relayer key … not found in keystore The relayer address is not in the keystore file.
BridgeAA … is bound to chain …, but BRIDGE_TARGET_CHAIN_ID is … The account's own chain_id differs from BRIDGE_TARGET_CHAIN_ID. Every intent would abort with EWrongTargetChain.
BridgeAA … has no ACL entry for (source_chain_id=…, source_sender=…) The relayer has no ACL entry under the source chain id. Every intent would abort with ESenderNotInAcl. Seed it with bridge_aa_init or add it with bridge_acl_add.
BridgeAA … owns no gas coins The account is the transaction sender, so it must hold its own coins. Funding the relayer is not enough.
BridgeAA account … is …, but an abstracted account must be shared or immutable The object is not a BridgeAA created by bridge_abstract_account::create.

Two further messages come from the worker, not from the account:

  • fewer gas coins than concurrent workers is a warning. Throughput is capped by the coin pool; split more coins or lower EVENT_HANDLER_CONCURRENCY.
  • Signer … not found in keystore stops the handler when EVENT_HANDLER_SIGNER is not in the keystore at EVENT_HANDLER_KEYSTORE_PATH.

When all checks pass, the log shows bridge mode ready with the account, the relayer, the signing scheme and both chain ids, then gas pool ready with the coin count.

To check a live account yourself, run this from testing_backend/. It reads the account's chain id and ACL on devnet through src/bridge/aa.rs:

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

Sending a request

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

Sending cross-chain requests explains each argument, the load generator route, the constraints on the call and how to read a failure.

Check it worked

  • The event handler log shows bridge mode ready, then gas pool ready with the coin count you expect.
  • After the request above, take the digest from the handler log and check on the destination chain that the status is success, the sender is the BridgeAA address, and a bridge_target::Recorded event was emitted.
  • With BRIDGE_PROTOCOL_PHASES=2, the row in bridge_results.csv has an empty failure_stage.

Next