This repo is meant for the cross chain child contracts for CGT. Ethereum layer 2's/sidechains and other chain information will be hosted in this repository, with smart contracts and tests in each chain hosted in their respectively named folders.
We create our own bridge contracts for the following reasons -
- Ability to fee exempt the bridge
- Ability to have a custom token across different chains
- Keep it simple
- Be able to have our own token with the fees on transfer model on other chains
- We should not do anything that generates fees for no reason
- We should not compromise usability for saving gas fees
- For now we will first just deploy, keep redemptions only on mainnet.
- In the next phase, we will deploy a simple redemption contract that allows us to transfer tokens to the mainnet redeem address.
We derive our contracts from FX-Portal repo, we create a simplified CGT contract and then deploy that as the Child contract with required FX extensions
Token -> RootTunnel -> FxRoot -> StateSender -> Checkpoints(Merrkle Tree, Heimdall nodes) -> FxChild -> RootChildContract -> ChildToken (Mints)
Current unit tests are used to verify that the upgraded CACHE Gold Contract behaves as expected.
Additional tests for cross chain in progress via matic.js sdk
- Get some goerli eth https://goerli-faucet.mudit.blog/
- Get some test CGT -> Send address to CACHE team
- Approve transfer of test CGT
- https://goerli.etherscan.io/token/0x1542ac6e42940476c729680ff147e0cedcfcfcf2
- Call approve where spender is 0xa56fc36C50873e23F2FC36AdaAA29A53c79743A9 and amount has 8 decimals
- Goto https://goerli.etherscan.io/address/0xa56fc36C50873e23F2FC36AdaAA29A53c79743A9#writeContract
- call
depositwhere rootToken (address) - "0x1542ac6e42940476c729680ff147e0cedcfcfcf2" childToken (address) - "0xbf0573f6B5B4eD806E8eA8F291A202e2fec21e7e" user (address) - "The address that should receive tokens on Mumbai" amount (uint256) - Amount to transfer 8 decimals data (bytes) - "0x00" - After 15 minutes/20 minutes verify your balance on polygon scan - https://mumbai.polygonscan.com/address/0xbf0573f6B5B4eD806E8eA8F291A202e2fec21e7e#readContract
Transfer from L2 to L1 requires first calling withdraw on child chain
- https://mumbai.polygonscan.com/address/0x1bdae4035879B1e4f4f507F17623E6BF8fA4092C#code
- Note down tx hash
- goto github/<cache-matic.js>/examples/pos/erc20/withdraw_exit.js
- Set the new transaction hash
- Execute the js script
We have made two modifications to the original matic.js files, both since there are some hard coding in the original js framework. Issue to be reported to the matic team.
In order to reduce the burden for our user's we will make this into a UI which they can then use their wallet to claim.
- Deploy Child Token
- Deploy Child tunnel
- Deploy Root Tunnel
- Run Child Tunnel Post Actions
- Run Root Tunnel Post Actions