Deploy using Truffle
To deploy smart contracts to the HPB network using truffle, you firstly need to install Truffle:
To verify that Truffle is installed properly, type truffle version
on a terminal. If you see an error, make sure that your npm modules are added to your path.
Create A Project
The first step is to create a Truffle project. We'll use the *SuperCoin as an example, which creates a token that can be transferred between accounts:
Create a new directory for your Truffle project
Initialize your project:
Once this operation is completed, you'll now have a project structure with the following items:
contracts/: Directory for Solidity contracts
migrations/: Directory for scriptable deployment files
test/: Directory for test files for testing your application and contracts
truffle-config.js: Truffle configuration file
Compile Contract
To compile a Truffle project, change to the root of the directory where the project is located and then type the following into a terminal:
Config Truffle for HPB
Go to truffle-config.js
Update the truffle-config with hpb-network-credentials.
Notice that the code requires a 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 the root directory and enter your 12 word mnemonic seed phrase to get started. To get the seed words from Metamask wallet, go to Metamask Settings, then from the menu choose Security and Privacy where you will see a button that says Reveal Secret Recovery Phrase.
Deploying on HPB Network
Run this command in the root of the project directory:
Your contract will be deployed to the HPB network, and will look similar to the example below:
Remember your address, transaction_hash and other details provided will differ. The code above is just to provide an idea of structure.
Last updated