YetAnotherBridge
  • 🌉Yet Another Bridge
  • About YAB
    • ⭐️ Features
    • 💻How does it work
    • ❓FAQ
  • Contracts
    • 💻Introduction
    • 🏦Escrow
      • 🏦Starknet
      • 🏦Zksync
    • 📜Payment Registry
    • 🔨Deploy
    • 📈Upgrade
    • ⛔️ Pause
  • Market Maker Bot
    • 🤖Introduction
    • 🤖Architecture
    • 🚀Deploy
  • Links
    • Telegram Group
    • Twitter/X
Powered by GitBook
On this page
  • Project Layout
  • How to Use
  • Local Tests
  • About Network Support:
  • How does a User set a new order?
  • How does a MM detect a User's new order?
  • How does a MM claim his payment?
  1. Contracts
  2. Escrow

Zksync

PreviousStarknetNextPayment Registry

Last updated 1 year ago

is a Smart Contract written in Solidity that resides in Ethereum's L2 , and is our implementation of our bridge's entity for this L2.

Project Layout

  • /contracts: Contains source files, solidity smart contracts.

  • /deploy: Scripts for contract deployment and interaction.

  • /test: Test files.

  • /artifacts-zk: Autogenerated with required libraries.

  • hardhat.config.ts: Configuration settings.

How to Use

  • make deps: Installs dependencies

  • make zksync-build: Compiles contracts.

  • make zksync-deploy: Deploys using script /deploy/deploy.ts.

  • make zksync-connect: Connects itself to saved PaymentRegistry address.

  • make zksync-deploy-and-connect: Deploys and connects itself to saved PaymentRegistry address.

  • make ethereum-and-zksync-deploy: Deploys both smart contracts and connects them to each other.

Local Tests

To run local tests you should first start a local dockerized node. For this you can:

git clone https://github.com/matter-labs/local-setup.git
cd local-setup
./start.sh

Then, to run the contract's tests:

make zksync-test

About Network Support:

hardhat.config.ts comes with a list of networks to deploy and test contracts. Add more by adjusting the networks section in the hardhat.config.ts. To make a network the default, set the defaultNetwork to its name.

You can also override the default using the --network option. For example: hardhat test --network dockerizedNode.

How does a User set a new order?

This contract recieves User's new orders with the function:

function set_order(address recipient_address, uint256 fee) public payable whenNotPaused returns (uint256)

Which returns the new order's ID.

How does a MM detect a User's new order?

When a new order is set, the following SetOrder Event is emitted, detectable by MM's:

event SetOrder(uint256 order_id, address recipient_address, uint256 amount, uint256 fee);

How does a MM claim his payment?

function claim_payment(
    uint256 order_id,
    address recipient_address,
    uint256 amount
) public whenNotPaused
function claim_payment_batch(
    uint256[] calldata order_ids,
    address[] calldata recipient_addresses,
    uint256[] calldata amounts
) public whenNotPaused

The claim_payment function is called, only by our , in order for the MM to retrieve its payment from the Escrow:

Alternatevly, the claim_payment_batch function is called, only by our , in order for the MM to retrieve many payments from the Escrow at once:

🏦
🏦
Escrow.sol
ZKSync
Escrow
Payment Registry
Payment Registry