Deploy a Smart Contract Using Remix
A step-by-step tutorial on how to create and deploy a smart contract on the Hedera network using Remix IDE.
Last updated
A step-by-step tutorial on how to create and deploy a smart contract on the Hedera network using Remix IDE.
Last updated
Remix IDE is an open-source tool for developing smart contracts in Solidity for the Ethereum network. It offers built-in compiling, debugging, and deploying features, streamlining the development process. This tutorial will leverage Remix IDE to create and deploy a simple smart contract on the Hedera network.
Web browser with access to Remix IDE.
Create a Hedera ECDSA testnet account.
Download the MetaMask wallet browser extension.
Before deploying a smart contract to the Hedera network using Remix, add Hedera Testnet as a custom network to MetaMask.
Open the MetaMask wallet extension and navigate to Settings > Networks > Add a Network > Add a network manually then add the Hedera Testnet details:
Switch the network to Hedera Testnet and add your account by importing your hex-encoded ECDSA private key to MetaMask.
➡ Here is a more comprehensive guide on importing a Hedera account into MetaMask.
Open your web browser and navigate to Remix IDE. Click on the file icon in the File Explorer tab to create a new file and name it HelloHedera.sol
.
Copy and paste this sample contract to the new file you created:
Navigate to the Solidity Compiler tab in the left sidebar and check that your compiler version is within the versions specified in the pragma solidity
statement. Then, compile your HelloHedera.sol
contract.
When a compilation for a Solidity file succeeds, Remix creates three JSON files for each compiled contract. Files can be seen in the File Explorers plugin
as:
artifacts/<contractName>.json
: contains the link to the libraries, the bytecode, the deployed bytecode, the gas estimation, the method identifiers, and the ABI. It is used for linking a library address to the file.
artifacts/<contractName_metadata>.json
: contains the metadata from the output of Solidity compilation.
artifacts/build-info/<dynamic_hash>.json
: contains info about solc
compiler version, compiler input and output. This file is generated similar to the files generated through Hardhat compilation. You can also try Hardhat compilation from Remix.
Please note that to generate these artifact files, the Generate contract metadata box in the General settings section of the Settings module needs to be checked. By default, it is checked.
Go to the Deploy & Run Transactions tab and select Injected Provider - MetaMask as the environment. A window will pop up if you're not signed into your MetaMask account. Sign in and make sure you're on Hedera Testnet and verify that the network is configured properly to Custom (296) network.
Once you click Deploy in the Deploy & Run Transactions tab, hit Confirm in the MetaMask notification window to approve and pay for the contract deployment transaction.
Once the transaction is successful, you can interact with the smart contract through Remix. Select the dropdown on the newly deployed contract at the bottom of the left panel to view the contract's functions under Deployed Contracts. Write a new message to the updateString
function using the input and confirm the write transaction in the MetaMask window to pay.
Copy the contract address from the Deployed Contracts window.
Navigate to the HashScan network explorer and use the contract address to search for your contract to view the details.
If you're up for it, you can verify your deployed contract using the HashScan Smart Contract Verifier tool. Learn how:
How to Verify a Smart Contract on HashScanCongratulations! 🎉 You have successfully deployed a smart contract on the Hedera network using Remix IDE. Feel free to reach out in Discord if you have any questions!