For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

  1. Create a new directory and initialize the project:

mkdir counter-contract
cd counter-contract
npm init -y
  1. Install required dependencies:

  1. 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

  1. Configure your network in hardhat.config.js:

  1. Deploy to Finney testnet:

Interact with Your Contract

After deployment, you can interact with your contract using:

  1. The Hardhat console:

  1. Example interactions:

Next Steps

Now that you've deployed your first contract, you can:

  1. Add more functionality to your contract

  2. Create a frontend to interact with it

  3. Learn about contract security and best practices

  4. 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