Backend scripts to help contracts read and write to each other on different blockchains.
The following network endpoint types were used:
-Local node synced (Prysm and Geth post merge)
-Infura WSS
-Alchemy WSS
-Quicknode WSS
-
Owner adds 1000 wei [ETH] (or another token) to another side of a bridge
-
User requests to bridge 1000 wei by paying 1003 wei (3 wei covers the 0.3% fee)
-
After deposit is made, user is added to the user bridge queue
-
Owner detects user in queue
-
Locally store user in queue with Golang variable
⚠️ Assume bridge will not go down with the stored address removed from queue.⚠️ -
Dequeue to remove user from the queue.
-
Unlock the added wei [ETH] (or another token) to the user locally stored, then remove user locally.
We remove the user locally between chains before the contract sends funds follow a "change state =>" then transfer pattern to prevent reentrancy attacks.
Ideally we remove the user from the queue like the mock Chainlink Keepers for simplicity.
If we had CCIP, we would be able to easily call between different contracts on different blockchains to have the same contract format.
For extra unlock security, the contract has
msg.sender != Owner
which would revert the unlock function call .
gvm use go1.17
cd GoerliBridgeToOptimism
cd GoerliBridgeToMumbai
go run ownerDeposit1000wei.go
go run userLock1000wei.go
go run ownerUnlock1000weiBlockListner.go
go run ownerWithdraw1000wei.go