Giter Site home page Giter Site logo

opbnb-bridge-bot's Introduction

opbnb-bridge-bot

Description

The opbnb-bridge-bot project primarily maintains a Layer2 contract named L2StandardBridgeBot. This contract, when called, initiates withdrawal transactions and collects a fixed fee for every withdrawals. The project promises that after the withdrawal transaction has can be proven and finalized after the required time window, a third-party account would complete the corresponding L1 proven withdrawal transactions and L1 finalized withdrawal transactions, thus completing the entire withdrawal process.

Motivation

image

A withdrawal request must be completed in three steps:

  1. Send a L2 initiating transaction
  2. Send the L1 proven transaction after the proposer submits the next L2 output root
  3. Send L1 finalized transaction after the challenge window has passed

Completing these three steps might not be a good user experience. Firstly, users need to send 3 transactions; secondly, they need to wait 2 periods before sending the next transaction.

See also

Design Principle and Working Mechanism

This project consists of an on-chain contract contracts/src/L2StandardBridgeBot.sol and an off-chain bot.

The L2StandardBridgeBot contract provides a withdrawTo function, which charges a fixed fee for every execution and then forwards the call to the L2StandardBridge.withdraw.

The off-chain bot watches the L2StandardBridgeBot.WithdrawTo events and based on these events, re-constructs the corresponding withdrawals. We name these withdrawals as bot-delegated withdrawals. As time go out of the bot-delegated withdrawal's proven and finalized time window, our bot will send proven and finalized transactions to complete the entire withdrawal process.

references

User Guide

Getting Started at opBNB testnet

  1. Prepare a MySQL database
docker-compose up -d
  1. Compile the off-chain bot and output the artifact to ./bot
make build-go
  1. Run the off-chain bot
OPBNB_BRIDGE_BOT_PRIVKEY=<bot privkey> ./bot --config ./bot.toml

Deploy and Use Contracts

  1. Compile the contract using forge
make build-solidity
  1. Deploy contract
cd contracts

export DELEGATE_FEE=1000000000000000
forge create \
    --rpc-url $OPBNB_TESTNET \
    --private-key $OP_DEPLOYER_PRIVKEY \
    src/L2StandardBridgeBot.sol:L2StandardBridgeBot --constructor-args $OP_DEPLOYER_ADDRESS $DELEGATE_FEE
  1. Withdraw via the deployed contract
export DELEGATE_FEE=1000000000000000
export amount=2000000000000001
export contract_addr=<deployed contract address>

cast send --rpc-url $OPBNB_TESTNET \
          --private-key $OP_DEPLOYER_PRIVKEY \
          --value $(($DELEGATE_FEE + $amount)) \
          $contract_addr \
          $(cast calldata 'withdrawTo( address _l2Token, address _to, uint256 _amount, uint32 _minGasLimit, bytes calldata _extraData)' 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000 $OP_DEPLOYER_ADDRESS $amount 150469 "")

License

MIT

opbnb-bridge-bot's People

Contributors

bendanzhentan avatar owen-reorg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.