This repo provides the code for several example of dApps utilizing Analog's General Message Passing protocol.
This project uses Forge Ethereum testing framework (like Truffle, Hardhat and DappTools). Install instructions: https://book.getfoundry.sh/
- Simple Counter: Increment a counter in a contract deployed at
Chain Aby sending a message fromChain B. - Teleport Tokens: Teleport ERC20 tokens from
Chain AtoChain B.
To start a new project with Foundry, use forge init
forge init hello_gmpThis creates a new directory hello_gmp from the default Foundry template. This also initializes a new git repository.
Install analog-gmp dependencies.
cd hello_gmp
forge install Analog-Labs/analog-gmp- To map the imports to the correct files, run the following command to create the
remmaping.txtfile in the project root directory:
forge remappings > remappings.txtobs: is important to run the command above only after install all dependecies.
- (optional) if you are using vscode, follow the instructions here:
All setup! now just need to import gmp dependencies from @analog-gmp:
import {IGmpReceiver} from "@analog-gmp/interfaces/IGmpReceiver.sol";
import {IGateway} from "@analog-gmp/interfaces/IGateway.sol";You can easily write cross-chain unit tests using analog's testing tools at @analog-gmp-testing.
import {GmpTestTools} from "@analog-gmp-testing/GmpTestTools.sol";
// Deploy gateway contracts and create forks for all supported networks
GmpTestTools.setup();
// Set `account` balance in all networks
GmpTestTools.deal(address(account), 100 ether);
// Switch to Sepolia network
GmpTestTools.switchNetwork(5);
// Switch to Shibuya network and set `account` as `msg.sender` and `tx.origin`
GmpTestTools.switchNetwork(7, address(account));
// Relay all pending GMP messages.
GmpTestTools.relayMessages();$ forge build$ forge test -vvv$ forge fmtAnalog's Contracts is released under the MIT License.