The Bridge contract facilitates ERC20 cross-chain transfers by handling deposits and withdrawals between supported chains. It ensures secure and validated token transfers using Merkle proofs and cryptographic signatures.
- ChainId target: The target chain ID where the tokens will be transferred.
- Token token: The token to be deposited.
- uint256 amount: The amount of tokens to be deposited.
- Creates a bridge message containing transaction details.
- Transfers the specified tokens from the sender to the contract.
- Emits a Deposit event with the encoded bridge message.
- BridgeMessage calldata bridgeMsg: The bridge message containing the details of the transaction.
- bytes32[] calldata proof: The Merkle proof validating the transaction.
- Validates the bridge message and Merkle proof.
- Determines the output token (wrapped or original).
- Transfers the specified tokens from the contract to the recipient.
- Emits a Withdraw event with the transaction details.
- UpdateHashMessage calldata updateMsg: The update message containing the new Merkle roots and block numbers.
- bytes[] calldata signatures: The cryptographic signatures validating the update.
- Validates the update message and signatures.
- Sets the new Merkle root for each specified block number.
- Emits an Update event with the update details.
- UpdateQuorumMessage calldata updateMsg: The update message containing the new signers.
- bytes[] calldata signatures: The cryptographic signatures validating the update.
- Validates the update message and signatures.
- Sets the new quorum of signers.
- Emits an UpdateQuorum event with the update details.
- SetChainConfigMessage calldata setMsg: The chain config message containing the new minimum confirmation.
- bytes[] calldata signatures: The cryptographic signatures validating the update.
- Validates the set message and signatures.
- Sets the new minimum confirmation for the specified chain.
- Emits a SetChainConfig event with the update details.
- Clone
$ git clone https://github.com/havi-kim/simple_bridge
$ cd simple_bridge
- Install foundry
$ curl -L https://foundry.paradigm.xyz | bash
$ foundryup
- Compile
$ forge build
- Test
$ forge test
- Run script
$ PK=0x... forge script scripts/....sol --rpc-url http://... --broadcast