This repo locks underlying $SHU tokens on Ethereum and mints synthetic tokens in Gnosis Chain and the other way around using the Gnosis OmniBridge.
- OmniBridge
- Proposal to deploy SHU on Gnosis
- Github Issue
- Shutter Token on Sepolia
- Shutter Token on Chiado
Start by installing the dependencies:
$ yarn
Then set the environment variables by copying the .env.example
file and removing the .example
extension, then fill in the values:
- RPC URLs: You can try public RPCs but they might not work properly. Try using Alchemy or Infura for this.
- PRIVATE KEY: The private key of the account that will be used to deploy the contracts.
- ALCHEMY KEY: The Alchemy key is an alternative
- ETHERSCAN KEY: Optional but recommended. Used to verify the contracts on Etherscan.
- SHUTTER TOKEN ADDRESS: The address of the Shutter Token contract deployed on each chain.
You can choose between deploying a new contract or use the existing contract that were previsouly deployed by Blockful. The contract addresses were already set in the .env.sample
file. you can directly mint new tokens by calling the mint
script.
$ yarn deploy --network sepolia
The contract should be deployed on Sepolia. This is because the Gnosis bridge only has support for Ethereum<>Gnosis and Sepolia<>Chiado at the moment. After deploying the Shutter Token, you need to set the SHUTTER_TOKEN_SEPOLIA
in the .env
file.
Optionally, you can verify the contract on Etherscan with:
$ npx hardhat verify --network sepolia <CONTRACT_ADDRESS> <OWNER_ADDRESS>
Can only be used after the Sepolia contract has been deployed.
$ yarn relay --network sepolia
This will relay the tokens from the Sepolia network to the Chiado network. The bridge works by locking the tokens on one side and minting them on the other side. When the tokens are being minted for the first time, the mediator contract will deploy an ERC677 proxy for a Permittable ERC20 token. The contract will only be deployed for the first time and the proxy will be used to mint the tokens on the other side from now on.
You will be needing to fetch the TX hash on the console and navigate to the Chiado Blockscout to fetch the contract that was deployed. Then change the value for the SHUTTER_TOKEN_CHIADO
in the .env
file.
Before bridging the tokens, make sure that you have a valid ERC20 set in SHUTTER_TOKEN_SEPOLIA
in the .env
file.
First you must approve the tokens to be bridged by calling the approve
script. It will approve the mediator contract to spend the tokens on your behalf. The mediator contract is also known as the OmniBridge contract.
$ yarn approve --network sepolia
You can bridge tokens by calling the relay
script. This will lock the tokens on one side and mint them on the other side.
$ yarn relay --network sepolia
NOTICE: Sepolia network is demonstrating strange behavior lately, with a lot of fluctiations in the gas fees and nodes stucking your transactions. If you are facing this issue, try adjusting the manual gas fees by uncommenting the maxFeePerGas
and maxPriorityFeePerGas
in the function. If the issue persist you can try using Alchemy SDK to send raw transactions. If the issue persists you can copy the data on the console of the resulting transaction and send it manually via browser wallet.
This method require the ALCHEMY_API_KEY
to be set in the .env
file.
$ yarn relay2
Before bridging the tokens, make sure that you have a valid ERC20 set in SHUTTER_TOKEN_CHIADO
in the .env
file.
You can bridge tokens by calling the transferAndCall
script directly in the ERC677 token contract. This will burn the tokens on one side and unlock them on the other side.
$ yarn transferAndCall --network chiado
You can mint more tokens on Sepolia by calling the mint
script. But you cant mint more tokens on the Chiado network. The tokens are minted on the Sepolia network and then relayed to the Chiado network.
$ yarn mint --network sepolia
This project is licensed under MIT.