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 |
-
Publish the packages:
bridge_sourceon the source chain,bridge_targetandbridge_abstract_accounton the destination chain. Take eachpackageIdfrom thepublishedentry ofobjectChanges, not the digest printed at the top. -
Create the source config. Publishing does not create it. The argument is the source chain id; keep the created object id, because every
requestcall takes it. -
Create the account. It prints the values to copy into
.env. The variables are described in Bridge account; the tool itself inbridge_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_initThe relayer is always seeded as the bootstrap ACL entry, because
createrejects an empty ACL. List every other address that will callrequestinBRIDGE_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
.envat your deployment.bridge_aa_initprints only theEVENT_HANDLER_MODE,BRIDGE_AA_*, chain id and ACL lines..env_sampleships 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_sourceEVENT_LISTENER_EVENT_TYPE=CrossChainRequestBRIDGE_TARGET_PACKAGE=<bridge_target package>(read bybridge_acl_addandbridge_aa_coins)- Either
BRIDGE_PROTOCOL_PHASES=2, orBRIDGE_PROTOCOL_PHASES=3withBRIDGE_SOURCE_CONFIG_ID=<the object id from step 2>. In 3-phase mode the acknowledgement goes to thatSourceConfig, so the sample's value would acknowledge on the author's config.
-
Fund the account with gas coins. The
BridgeAAis the sender of every bridged transaction, so the coins must belong to it, not to the relayer. Send it many equal coins withiota client pay-iota, or re-split its balance withbridge_aa_coins. How many, and how large, is the subject of Gas pool sizing. -
Deploy with
./deploy.shand wait forbridge mode readyin 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 workersis a warning. Throughput is capped by the coin pool; split more coins or lowerEVENT_HANDLER_CONCURRENCY.Signer … not found in keystorestops the handler whenEVENT_HANDLER_SIGNERis not in the keystore atEVENT_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:
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, thengas pool readywith 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
BridgeAAaddress, and abridge_target::Recordedevent was emitted. - With
BRIDGE_PROTOCOL_PHASES=2, the row inbridge_results.csvhas an emptyfailure_stage.
Next¶
- Sending cross-chain requests: the arguments, the load generator route and the errors.
- Gas pool sizing: how many coins, how rich, and what
BATCH_SIZEdoes to the answer. - Managing the ACL: authorise more source senders.