This project is a full-stack decentralized application (dApp) built with React/Nextjs, Solidity, and Axelar General Message Passing. It enables users to send messages between two blockchain chains.
- Send messages between two blockchain chains
- User-friendly interface with dark mode support
- Integration with Axelar General Message Passing
- Real-time response and message status updates
To install and run this application locally, follow these steps:
-
Clone the repository:
git clone https://github.com/Olanetsoft/javascript-on-chain-demo.git
-
Navigate to the project directory:
cd javascript-on-chain-demo
-
Install the dependencies:
npm install
-
Navigate to the hardhat directory:
cd hardhat
-
Set up the environment variables to deploy the smart contracts:
- Create a
.env
file in the hardhat directory. - Define the following variables in the
.env
file:ReplacePRIVATE_KEY=<Your Wallet Private Key>
<Your Wallet Private Key>
with your wallet private key.
- Create a
-
Compile and Deploy the smart contracts:
npx hardhat run scripts/deploy.js --network <network>
Replace
<network>
with the desired network (e.g.bsc
andavalancheFujiTestnet
in this case). Copy the contract address once the deployment is complete.Ensure you update the Axelar gateway and gas service address for Binance and Avalanche respectively in
deploy.js
file under thescripts
directory and deploy them seperately. You can find the gateway and gas service address here. -
Set up the environment variables:
- Create a
.env.local
file in the root directory. - Define the following variables in the
.env.local
file:ReplaceNEXT_PUBLIC_BSC_CONTRACT_ADDRESS=<BSC contract address> NEXT_PUBLIC_AVALANCHE_CONTRACT_ADDRESS=<Avalanche contract address> NEXT_PUBLIC_AVALANCHE_RPC_URL=https://avalanche-fuji-c-chain.publicnode.com
<BSC contract address>
and<Avalanche contract address>
, with the respective values.
- Create a
-
Start the development server:
cd ..
npm run dev
- Access the application in your browser:
Open your web browser and visit http://localhost:3000
to see the application running.
-
Connect your wallet:
- Click on the "Connect" button to connect your wallet.
- Follow the prompts to connect to the desired blockchain network.
-
Sending a message:
- Enter your message content in the "Send Message" section.
- Click the "Send" button to send the message.
- A toast notification will appear, indicating that the message is being sent.
-
Response:
- The "Response" section will display the received message once it is successfully delivered.
- A "waiting for response..." message will be displayed if the message has not yet been received.
The following technologies and frameworks were used in this project:
- React
- Solidity
- Axelar General Message Passing
- @rainbow-me/rainbowkit
- wagmi
- ethers.js
- Next.js
- Toastify
- CSS (Tailwind CSS)
Contributions are welcome! If you find any issues or want to contribute to the project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them with descriptive messages.
- Push your changes to your forked repository.
- Submit a pull request detailing your changes.
This project is licensed under the MIT License.