This repository contains a simple Message Service dApp that serves as a bridge between Ethereum equivalent chains. The dApp allows you to create and store messages on a source chain and verify their inclusion on a destination chain using Merkle proofs. This lays down the core principles of a bridge application but not at all a production ready Bridge (!!!) - educational material only.
- The dApp deploys the same smart contract on both the source chain and the destination chain.
- Both contracts have the ability to create and store messages at specific storage slots with the value
0x1
. - You can use
eth_getProof
RPC calls to obtain the Merkle proof of inclusion for a specific message on the source chain. - This proof can then be presented to the destination chain's smart contract to verify that a specific message has been sent.
Before setting up the project, ensure you have Foundry installed.
Follow these steps to set up the project:
-
Clone the repository:
git clone git@github.com:adaki2004/MessageService.git cd MessageService
-
Install project dependencies:
forge install
-
If you want to test a specific message (located in the test/ folder), replace the message string and Ethereum address. Then run the tests using Foundry:
forge test -vv
-
Deploy (and verify) the smart contracts on both chains using Foundry. Here's an example deployment script (for Sepolia):
forge create --rpc-url 'https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY' --private-key 'YOUR_DEPLOYER_WALLET_PRIV_KEY' --etherscan-api-key 'YOUR_ETHERSCAN_API_KEY' --verify 'src/MessageService.sol:MessageService'
Make sure to replace 'https://eth-sepolia.g.alchemy.com/v2/ALCHEMY_API_KEY', 'YOUR_DEPLOYER_WALLET_PRIV_KEY', and 'YOUR_ETHERSCAN_API_KEY' with the appropriate values.
-
Set the message slot value to
0x1
by calling thesendMessage
function on the source chain. -
Call the RPC
eth_getProof
with the contract address and storage slot using the script/eth_getProof.py script. (The raw proof bytes are not RLP encoded so make sure you encode it! For example, you can use: https://toolkit.abdk.consulting/ethereum#key-to-address,rlp ) -
Verify on the destination chain's smart contract using the
verifySourceChainMessage
function, providing the proof that the specific message has been sent.
Pre-deployed address (Goerli): 0xBdE80AC952B3c2B01786992B9C99777a66e443a9
Pre-deployed address (Sepolia): 0xBdE80AC952B3c2B01786992B9C99777a66e443a9
Please note that this is a basic implementation of a bridge application and is not intended for production use.
This project is licensed under the MIT License.