@pooltogether/pooltogether-evm-bridge
v1.0.0
Published
PoolTogether EVM Bridge -> Matic
Downloads
4
Readme
PoolTogether EVM Bridge
An ownable half-duplex bridge to send Messages
from a Root Chain to a Child Chain using Matic Networks PoS State Sender Bridge.
The FxPortal contracts are used to integrate with this bridge.
Usage
Format a message call as the following struct:
struct Message {
uint8 callType;
address to;
uint256 value;
bytes data;
}
Where:callType
: 0 if call, 1 if callDelegateaddress
: destination address on Child chainvalue
: value to be send on Child chaindata
: the encoded data encapsulating the call on the Child chain\
This encoded data can be encoded using ethers.js encodeFunctionData()
such as:
const testContract : Contract = await ethers.getContractAt("TestContract", address)
const encodedTxData = testContract.interface.encodeFunctionData(testContract.interface.getFunction("setNumber(uint256)"),[setNumberValue])
execute(Messages[] messages)
can be called by the contract owner (PoolTogether governance) to execute arbitrary calls on the child chain.
Installation
Install the repo and dependencies by running:
nvm use && yarn
Deployment
These contracts can be deployed to a network by running:
yarn deploy <networkName>
The PoolTogetherEVMBridgeRoot
contract should be deployed on the "parent" chain - yarn deploy mainnet
The PoolTogetherEVMBridgeChild
contract should be deployed on the "child" chain - yarn deploy matic
Testing
Run the unit tests locally with:
yarn test
Integration Test Steps
- Deploy to both Root (e.g. Goerli) and Child testnets (e.g. Mumbai) and verify on Root Chain
- Set
fxChildTunnel
address onPoolTogetherEVMBridgeRoot
- use goerli.etherscan.io - Set
fxRootTunnel
address onPoolTogetherEVMBridgeChild
- usehardhat run ./scripts/setTunnels --network mumbai
- Deploy the
TestContract
to the Child Network - Format
setNumber()
orsetString()
transaction targetingTestContract
and send from address owner ofPoolTogetherEVMBridgeRoot
in Message Format - Observe logs on
TestContract
- should update within a period of time to values set
Coverage
Generate the test coverage report with:
yarn coverage