🚌 A shuttle to batch cross-chain transfers using ChainBridge and lower fees.
This project was meant to be plugged on top of the first version of the Avalanche-Ethereum bridge that was implemented with ChainBridge.
This first implementation was generating a lot fees and thus it seemed interesting to batch transfers to/from Avalanche. Now that a new low-fee version of the bridge has been deployed, it makes a lot less sense and I stopped developing it.
- Find a way to generate ERC20 token and send them to an address ->
$TAXItoken generated bycb-sol-cli -
registerDeposit()should accept any ERC20 token - ChainBridge
- Deploy contracts on 2 chains
- Setup
gethinstead ofganache-cli - Setup ERC20 contracts as mintable/burnable
- Setup
chainsafe/chainbridgeDocker container
- Refactor storage to be able to iterate through keys
- Limit to 1 type of ERC20 token per deposit
-
registerDeposit()- Allow ERC20Handler to withdraw from ChainBridge contract with
approve - Send ERC20 tokens through the bridge when shuttle capacity is reached
- Define encoding for dispatch bytes message
- Send dispatch bytes message through the bridge when shuttle capacity is reached
- Embed
dataHashanddepositNonceof the ERC20 deposit in dispatch message.dataHashcomputing
- Allow ERC20Handler to withdraw from ChainBridge contract with
- Use a dedicated function to send the dispatch message (to avoid dispatch to happen if the ERC20 deposit has not been executed)
-
offloadShuttle()- Register claimable deposits in state
- Use destination chain GenericHandler address in
dataHashcomputation - Check that ERC20 deposit proposal has passed before registering claimable deposits (using
dataHashanddepositNonce) - Unable to offload a shuttle several times by storing a boolean per
dataHash+depositNonce
- Test cross-chain message sending/reception
- Implement a ChainBridge GenericHandler to only allow the shuttle contract to deposit messages
- Gas optimization
- Configure realistic gas price
- Benchmark
require()+ events gas cost - Refund the user that payed gas for
sendShuttle()(ERC20 token?)
Install cb-sol-cli. See their README.md.
git clone https://github.com/ChainSafe/chainbridge-deploy.git
cd chainbridge-deploy/cb-sol-cli
yarn install
make install- Install Go and set
$GOPATHin your env. - Install and build avalanchego and avash with sources:
go get github.com/ava-labs/avash GO111MODULE=off go get github.com/ava-labs/avash GO111MODULE=off go get github.com/ava-labs/avalanchego cd $GOPATH/src/github.com/ava-labs/avalanchego ./scripts/buid.sh cd $GOPATH/src/github.com/ava-labs/avash go build
Start 2 chains and setup the chainbridge:
yarn install
yarn developyarn testCommits have to respect Conventional Commits. They are enforced using commitlint and husky.
Use npx cz to easily generate commit messages (see commitizen).