Your first EVM Smart Contract
Your First Smart Contract
Overview
In this guide, we'll create, deploy, and interact with a simple smart contract on UOMI's EVM network using Hardhat. We'll build a basic "Counter" contract that can increment and retrieve a number.
Prerequisites
Before starting, ensure you have:
Node.js installed
A code editor (VS Code recommended)
A MetaMask wallet with some test tokens
Basic knowledge of Solidity
Project Setup
Create a new directory and initialize the project:
mkdir counter-contract
cd counter-contract
npm init -yInstall required dependencies:
Create a Hardhat project:
Select "Create a JavaScript project" when prompted.
Writing the Contract
Create a new file contracts/Counter.sol:
Deployment Script
Create/modify scripts/deploy.js:
Test the Contract
Create test/Counter.js:
Run the tests:
Deploy to Testnet
Configure your network in
hardhat.config.js:
Deploy to Finney testnet:
Interact with Your Contract
After deployment, you can interact with your contract using:
The Hardhat console:
Example interactions:
Next Steps
Now that you've deployed your first contract, you can:
Add more functionality to your contract
Create a frontend to interact with it
Learn about contract security and best practices
Explore more complex smart contract patterns
Common Issues and Solutions
⚠️ Common Problems
Transaction Failed: Make sure you have enough tokens for gas
Contract Not Found: Verify the contract address is correct
Network Issues: Ensure you're connected to the correct network
Resources
Last updated

