# Truffle
Set up a Truffle Ethermint local development environment.
# Pre-requisite Readings
Truffle is a development framework for deploying and managing Solidity smart contracts. In this guide, we will learn how to deploy a contract to a running Ethermint network.
# Install dependencies
First, install the latest Truffle version on your machine globally.
You will also need to install Ethermint. Check this document for the full instructions.
# Create Truffle Project
In this step we will create a simple counter contract. Feel free to skip this step if you already have your own compiled contract.
Create a new directory to host the contracts and initialize it
Initialize the Truffle suite with:
Create contracts/Counter.sol
containing the following contract:
Compile the contract using the compile
command:
Create test/counter_test.js
containing the following tests in Javascript using Mocha:
# Truffle configuration
Open truffle-config.js
and uncomment the development
section in networks
:
This will allow your contract to connect to your Ethermint local node.
# Start Node and REST server
Start your local node using the following command on the Terminal
For further information on how to run a node, please refer to this quickstart document.
In another Terminal wintdow/tab, start the REST and JSON-RPC server:
# Deploy contract
Back in the Truffle terminal, migrate the contract using
You should see incoming deployment logs in the Ethermint daemon Terminal tab for each transaction (one to deploy Migrations.sol
and the oether to deploy Counter.sol
).
# Run Truffle tests
Now, you can run the Truffle tests using the Ethermint node using the test
command:
# Next
Learn how to connect Ethermint to Metamask