Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Go to https://remix.ethereum.org/
Copy and paste the code below to Counter.sol file
If you want to deploy the contract to a live network like Harmony Testnet or Mainnet, configure your metamask by adding the required Harmony networks using this guide.
This guide shows instructions on how to deploy smart contracts using Harmony remix ide.
Open Harmony Remix IDE in your browser.
On opening the IDE, in the left panel, click the "+" icon to create a new solidity file:
Now click on the new file in the navigation panel, if not opened already. Now start writing your code in the window opened on the right hand side. For this demo we are going to use a simple counter smart contract:
Following is the code used in the demo image above:
In the left navigation bar select "Solidity Compiler". In the new window choose the solidity version and modify other settings if required. Finally click on the Compile button to compile your solidity code:
After successful compilation, go the navigation panel once again, and click on the "Harmony" button. Now in the new panel, select the network to deploy on, and choose and connect to your desired wallet. For this demo we are using Math Wallet. Now click on "Deploy" to deploy your smart contract to Harmony Network:
You have now successfully deployed your smart contract on harmony network!
This guide walks you through the process of using the Solidity compiler and web3.js to deploy and interact with a Solidity-based smart contract on Harmony. Given Harmony's Ethereum compatibility features, the web3.js library can be used directly with a Harmony node.
Completed code can be found here.
.env
in rootcompile.js
The only purpose of the compile.js
file, is to use the Solidity compiler to output the bytecode and interface of our contract.
deploy.js
You just deployed your first smart contract on Harmony using web3.js.
This page describes in detail how to deploy a smart contract on to Harmony using an example
The smart contract demo example used in this tutorial can be found in the following github repository.
Harmony Box is a Truffle box that will get you quickly up and running deploying smart contracts on Harmony using Truffle & native Ethereum tooling.
Since Harmony is fully EVM-compatible (Ethereum Virtual Machine), it makes it really easy to port existing contracts to Harmony. Here's a short demo on how to port an existing Ethereum smart contract to the Harmony testnet:
If you have an idea that you'd like to deploy on the Harmony Protocol, you might be interested in learning about the Harmony Grant Program.
This section covers writing a custom smart contract and deploying it on Harmony Testnet.
In the contracts folder create a new file Counter.sol
and add the following code block to it:
In the migrations folder create another new file called 2_Counter.js
and add the following code block:
If all was done correctly you should see something like this:
1. Install truffle (preferably v5.3.0+, sometimes with v5.1.33, @truffle/hdwallet-provider
does not work)
2. Create a metacoin project, unbox metacoin truffle box, and install @truffle/hdwallet-provider
3. Modify truffle-config.js
to add Harmony networks. Make sure to add your mnemonic or private key.
4. Compile and deploy
The following tools need to be installed:
Node Package Manager (npm)
You might be require to provide super user privileges to install it.
Navigate to the directory where you want to setup you project. For this guide we will be using "demo" as the project name.
(Optional) Install Additional Dependencies if required. We wont be using this for this demo.
Create a .env
file in the project root directory and put your mnemonic code, private key, and rpc url in it. We will be using the following structure for our demo.
In the project root directory, there is a file truffle-config.js
and copy paste the following configuration.
This section describes how to deploy a HRC20 smart contract on Harmony in 1-minute.
This section is designed to get the casual smart contract developer deploying HRC20 tokens (Harmony's ERC20 equivalent) on Harmony Network. This can be done in under one Minute.
This github repository contains the code and files used on this demo. You can also find many more examples that use HRC20 tokens on this github repository.
Here is a short video running through the deployment:
Follow until step 7 of the
Add Harmony testnet or mainnet entries to hardhat.config.js
file.
Finally run:
https://explorer.harmony.one/verifycontract
Right now, we support verification only for one single solidity file - therefore, before deployment and verification, you will need to flatten all solidity sources to one file.
To flatten your solidity files we recommended to use Truffle Flattener lib.
Or you can use any other flattener lib.
To easy the verification we recommend the contract deployment using Harmony Remix.
You can verify your contract here: https://explorer.harmony.one/verifycontract
It is important to use the correct parameters (same as on deployment):
Contract address
Contract name
Compiler version
Optimizer
Chain Type (mainnet or testnet)
Sources
Imported libs
Then click on Submit button. If all params are correct - you should to see a Success message, or an Error if bytecodes are not equal. On Success case - your contract will verify and you will see all contract details on contract explorer page.