Deploying Move Smart Contract
In this guide, we will walk through deploying a simple Move smart contract on Umi. We'll use a basic counter example, build the contract using Umi SDK, deploy it with Hardhat.
1. Setting Up the Hardhat Environment
-
Install Hardhat and required dependencies:
-
Initialize a Hardhat project:
Follow steps with the
Create an empty hardhat.config.js
option. -
Add the Umi plugin and network description to
hardhat.config.js
:Make sure to put in your private key in place of
YOUR_PRIVATE_KEY
. You can obtain this key from your crypto wallet. We recommend creating a burner account for testing.
2. Creating a Move Smart Contract
We'll start with a simple counter contract that increments a stored value. First, create a contracts/counter
folder to keep our Move contract project.
Inside this folder run the following command to create a simple counter project:
If the command fails, ensure the CLI is installed correctly for Move project compilation, following the Installation step.
Inside the contracts/sources/
folder create a file named counter.move
and paste the following in the file:
Next we'll define our example
address in the Move.toml
file. So, add your wallet address under the [addresses]
list replacing the ACCOUNT_ADDRESS
.
In the same file change the rev
of the Aptos Framework dependency to the latest supported version. The final Move.toml
should look like:
Finally let's compile the Move contract, from the top project folder:
3. Deploying the Contract
-
Create a script to deploy the generated contract artifact. Create a file under
scripts/deploy.js
with the following code. Make sure thescripts
folder is inside the Hardhat folder and not thecounter
project folder. -
Ensure your wallet has sufficient test ETH for the address used above. Get tokens from the Faucet.
-
Deploy the contract using a single command, Hardhat takes care of the rest:
-
After deployment, locate your contract on the Umi block explorer. Search the deployer address to verify its status and details.
With these steps, you've successfully deployed and now checkout Use Contract to interact with your Move smart contract!
Set up your IDE
An overview of the Move programming language and the Umi Network blockchain.
Interacting with Your Deployed Move Smart Contract
In this guide, we will create a simple website that interacts with your deployed Move smart contract. The website will allow users to increment the counter and display its current value using Move transactions and Viem SDK.