This repository contains basic dApp examples for interacting with a simple Storage smart contract deployed on Westend Asset Hub. These examples demonstrate how to connect wallets, read contract state, and write to the contract using different popular JavaScript libraries.
The examples interact with a minimal Storage smart contract that allows storing and retrieving a number value:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
contract Storage {
// State variable to store our number
uint256 private number;
// Event to notify when the number changes
event NumberChanged(uint256 newNumber);
// Function to store a new number
function store(uint256 newNumber) public {
number = newNumber;
emit NumberChanged(newNumber);
}
// Function to retrieve the stored number
function view returns (uint256) {
return number;
}
}
The repository contains the following implementations:
- ethers-dapp - dApp implementation using ethers.js
- viem-dapp - dApp implementation using viem
Each example demonstrates:
- Connecting a wallet
- Reading the current stored number
- Updating the stored number
Each example has its own README with specific setup instructions. To get started with either example:
- Clone this repository
- Navigate to either the
ethers-dapp
orviem-dapp
directory - Follow the instructions in the respective README.md file
Contributions are welcome! Please feel free to submit a Pull Request.