Contract Execution
Contract
Hepton
use EVM
for contract execution. See Solidity for detail.
Remix
Remix IDE is an open-source web and desktop application. It fosters a fast development cycle and has a rich set of plugins with intuitive GUIs. Remix is used for the entire journey of contract development as well as being a playground for learning and teaching contract development.
Create new file in file explorer. Edit contract info at right side.
Compile contract
Click the compiler button, switch the UI
Select the contract you want to compile
Set compile flags
Click compile button
Deploy contract to blockchain via wallet such as MetaMask
.
Step1. Set network info in Metamask
.
Step2. Back to Remix
.
Swich environment
Select contract
click deploy button
And then by MetaMask
the contract deployment transaction can be broadcasted to the Hepton POS.
Truffle
Use truffle to compile and deploy contract. + Install Node.js See Installing Node.js for detail.
Install truffle
Run truffle version
after installation finished. If the command line displays a message like below, installation is successful.
Create project
First, create folder for project.
Then, initialize project via truffle
After initialization is complete, the following file structure is generated within the project.
Config truffle info
Create contract
Put custom contracts into folder contracts
and modify the deployment script script in folder migrations
.
Deploy contract
Run the deployment command.
The output as below.
Finally, the contract deployment is complete.
Hardhat
Using Hardhat
What is Hardhat
Hardhat is a development environment to compile, deploy, test, and debug your smart contract.
Setting up the development environment
There are a few technical requirements before we start. Please install the following: Requirements:
Installing
There are a few technical requirements before we start. Please install the following: Requirements:
Windows, Linux or Mac OS X
Node.js v8.9.4 LTS or later
Git
First, you need to create an empty project npm init --yes
Once your project is ready, you should run
It's recommeded to install some dependencies.
To use your local installation of Hardhat, you need to use ``npxto run it (i.e.
npx hardhat```).
Create A Project
To create your Hardhat project run npx hardhat in your project folder:
Intialize your project:
Once this project is initialized, you'll now have a project structure with the following items:
contracts/: Directory for Solidity contracts
scripts/: Directory for scriptable deployment files
test/: Directory for test files for testing your application and contracts
hardhat-config.js: Hardhat configuration file
Create Contract
You can write your own smart contract.
Config Hardhat for HTE
Go to hardhat.config.js
Update the config with L2Hepton-crendentials.
!!! Note It requires mnemonic to be passed in for Provider, this is the seed phrase for the account you'd like to deploy from. Create a new .secret file in root directory and enter your 12 word mnemonic seed phrase to get started. To get the seedwords from metamask wallet you can go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says reveal seed words.
Compile Contract
To compile a Hardhat project, change to the root of the directory where the project is located and then type the following into a terminal:
Deploying on HTE Network
Run this command in root of the project directory:
Remember your address, transaction_hash and other details provided would differ, Above is just to provide an idea of structure.
Congratulations! You have successfully deployed CRC20 Smart Contract. Now you can interact with the Smart Contract.
You can check the deployment status here: https://testnet.heptonscan.com/ or https://www.heptonscan.com/
Smart Contract Verification
note: Currently supports browser verify contracts for the time being, Plug-in verification will be supported later
How to Verify Your Contract on HeptonScan
Step 1: Deploy your contract on Hepton
Step 2: Go to Hepton Explorer or Testnet Explorer
Click on "Verify and Publish"
Contract Address
Compiler Type you chose in Remix or other complier
Select Open Source License Type
Step 3: Fill in the correct information of your contract
You need to select "Yes" for Optimization, if that's enabled.
Contructor arguement is optional. If your contract do have one, you can go to this page to generate the encoded ABI json.
!!! info
Click on "Verify and Publish" to finish this process. Now you are all set!
Last updated