Skip to content

B2AGG (Bridge-to-AggLayer) note #1898

@mmagician

Description

@mmagician

Bridging summary
The overall flow for bridging out from Miden -> AggLayer

  1. The user creates a Bridge-to-AggLayer (B2AGG) note with ASSET to be bridged out, and sends it to the AggLayerBridgeOut contract
  2. The AggLayerBridgeOut account verifies that the faucet for the ASSET in the note is in the faucet registry it maintains. It then,
    1. Makes an FPI call to this AggLayerFungibleFaucet to call its convert_asset procedure and get the Ethereum-native representation of the token's amount + address.
    2. Hashes the information about the asset to be bridged out to obtain a hash value, and appends it to a Local Exit Tree (a Merkle Tree) it maintains - only the frontier branch is needed at any given time, not the full tree.
    3. Sends a burn note with the original asset to the AggLayerFungibleFaucet
    4. The faucet will consume the note and burn the contained asset.

B2AGG note interface

(this is pretty simple, the code below might already work)

use.miden::note
use.miden::contracts::agglayer::bridge

const.ERR_B2AGG_WRONG_NUMBER_OF_ASSETS="B2AGG script requires exactly 1 note asset"

#! Inputs:  []
#! Outputs: []
#!
#! Note inputs are assumed to be as follows:
#! - destination_network (AggLayer-defined network ID)
#! - DESTINATION_ADDRESS (destination network's target address)
#!
begin
    # store the number of note assets to memory starting at address 0
    push.0 exec.active_note::get_assets
    # => [num_assets, ptr]

    # make sure the number of assets is 1
    assert.err=ERR_B2AGG_WRONG_NUMBER_OF_ASSETS
    # => [ptr]

    # load the ASSET
    mem_loadw
    # => [ASSET, destination_network, DESTINATION_ADDRESS]

    call.bridge::bridge_asset_out
    # => []
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    agglayerPRs or issues related to AggLayer bridging integrationstandardsRelated to standard note scripts or account components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions