The Zelana Bridge is a Solana-based program built using the Pinocchio. It enables the transfer of assets with a sequencer-based withdrawal mechanism, suggesting it is designed for integrations that require attested or privacy-preserving transactions.
The bridge operates on a simple yet powerful model:
- Initialization: A one-time setup to configure the bridge's operational parameters, including a trusted sequencer.
- Deposits: Users can deposit assets into a secure vault, and a receipt is generated on-chain to prove the transaction.
- Withdrawals: Withdrawals are processed by a trusted sequencer, which validates the request and authorizes the release of funds. This process uses a nullifier to prevent replay attacks and ensure that each withdrawal is unique.
The bridge's functionality is divided into three main instructions:
-
Initialize: This instruction sets up the bridge by creating aConfigaccount and aVaultaccount. TheConfigaccount stores essential parameters, such as thesequencer_authority, which is the public key of the trusted sequencer authorized to approve withdrawals. TheVaultis a PDA that securely holds all deposited assets. -
Deposit: When a user deposits assets, theprocess_depositfunction transfers the funds into theVault. It then creates aDepositReceiptaccount, which serves as an on-chain record of the deposit, containing details like the depositor's public key, the amount, a unique nonce, and a timestamp. -
WithdrawAttested: The withdrawal process is managed by theprocess_withdraw_attestedfunction and initiated by thesequencer. To withdraw funds, the sequencer provides a uniquenullifierto prevent double-spending. The bridge verifies the sequencer's authority and then transfers the specified amount from theVaultto the recipient's account. AUsedNullifieraccount is created to ensure the same nullifier cannot be used again.
The bridge uses the following on-chain accounts:
Config: Stores the bridge's configuration, including thesequencer_authorityand adomainidentifier.Vault: A PDA that holds all deposited assets.DepositReceipt: A PDA created for each deposit, acting as a proof of the transaction.UsedNullifier: A PDA created for each withdrawal to mark a nullifier as used and prevent replay attacks.
The program exposes the following instructions:
| Instruction | Description | Accounts Required |
|---|---|---|
Initialize |
Initializes the bridge by creating the Config and Vault accounts. |
payer, config_account, vault_account, system_program |
Deposit |
Deposits assets into the bridge and creates a DepositReceipt. |
depositor, config_account, vault_account, deposit_receipt_account, system_program |
WithdrawAttested |
Withdraws assets from the bridge, authorized by the sequencer and using a unique nullifier. | sequencer, config_account, vault_account, recipient, user_nullifier_account, system_program |
The repository includes a gen-client.sh script, which is used to generate a client-side library for interacting with the on-chain program. The generated client can be found in the client/ directory.
./gen-client.shTo build and test the program, you can use the following commands:
cargo build-sbfcargo testThe on-chain program ID for the Zelana Bridge is: 95sWqtU9fdm19cvQYu94iKijRuYAv3wLqod1pcsSfYth