Introduction
Imagine if you could build a decentralized application that could interact with multiple blockchains, delivering a message in less than one minute, without having to worry about the underlying infrastructure. With Equito, you can do just that.
This tutorial will guide you through the whole process of writing, testing and deploying your first Equito App using Solidity. The smart contract will be a simple ping-pong mechanism:
- Upon request, the contract on a chain A will send a "ping" message to a chain B.
- When receiving the "ping" message, the contract on chain B will send a "pong" message back to chain A.
- The contract on chain A will receive the "pong" message.
Let's get started by setting up your local environment and creating a new project, using your favorite framework for building EVM-compatible smart contracts.
Prerequisites
- Foundry
- Hardhat
If Foundry is your preferred tool for building and deploying smart contracts, you can follow this guide to create a new project and set up the Equito EVM contracts as a dependency.
To install Foundry, please refer to the official guide.
If you want to use Hardhat to build and deploy your smart contracts, this tutorial will guide you through creating a new project using the Equito Hardhat Template, which includes contracts from the equito-evm-contracts repository.
To install Hardhat, please refer to the official guide.
Initialize your project
- Foundry
- Hardhat
To initialize your new project with Foundry, run the following command in your terminal:
forge init equito-ping-pong
This command sets up a new Foundry project in a directory named equito-ping-pong
.
Next, add the Equito contracts as a submodule to your project. This ensures you have the latest version of the Equito contracts as a dependency:
git submodule add -f https://github.com/equito-network/equito-evm-contracts.git lib/equito
git submodule update --init --recursive
This will clone the Equito contracts into the lib/equito
directory and initialize the submodule.
Open the Equito Hardhat Template on GitHub and click on the "Use this template" button in the top-right corner to create a new repository based on the template.
Clone the repository to your local machine, then navigate to your project directory and run the following command to install dependencies:
npm install
Initialize PingPong.sol
- Foundry
- Hardhat
Create a new file PingPong.sol
in the src/
folder. By following this tutorial, you will implement the logic for the PingPong
contract in the next step. Meanwhile, you can add the following code to import the necessary libraries and declare the contract structure:
pragma solidity ^0.8.23;
import {EquitoApp} from "equito/src/EquitoApp.sol";
import {bytes64, EquitoMessage, EquitoMessageLibrary} from "equito/src/libraries/EquitoMessageLibrary.sol";
/// @title PingPong
/// @notice This contract implements a simple ping-pong message exchange using the Equito cross-chain messaging protocol.
contract PingPong is EquitoApp {
// The contract logic goes here...
}
Create a new file PingPong.sol
in the contracts/
folder. By following this tutorial, you will implement the logic for the PingPong
contract in the next step. Meanwhile, you can add the following code to import the necessary libraries and declare the contract structure:
pragma solidity ^0.8.23;
import {EquitoApp} from "../lib/equito/src/EquitoApp.sol";
import {bytes64, EquitoMessage, EquitoMessageLibrary} from "../lib/equito/src/libraries/EquitoMessageLibrary.sol";
/// @title PingPong
/// @notice This contract implements a simple ping-pong message exchange using the Equito cross-chain messaging protocol.
contract PingPong is EquitoApp {
// The contract logic goes here...
}
Now that you have set up your project and initialized the PingPong.sol
contract, you are ready to implement the logic for the PingPong
contract. Continue to the next section to learn how to implement the ping-pong mechanism between different blockchains using Equito.