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
mkdir truffle
cd truffle
truffle unbox truffle
npm install --save-dev @truffle/hdwallet-provider
3. Create deploy script ./migrations/1_deploy_contracts.js
const helloHyperasChain = artifacts.require("HelloHyperasChain");
module.exports = function(deployer) {
deployer.deploy(helloHyperasChain)
.then(() => helloHyperasChain.deployed())
.then(_instance => console.log("helloHyperasChain deployed to:", _instance.address));
};
4. Modify truffle-config.js
to add Hyperas Chain networks. Make sure to add your mnemonic or private key.
const HDWalletProvider = require('@truffle/hdwallet-provider');
const mnemonic = '<ADD-YOUR-MNEMONIC-HERE>';
const privateKeyTest = '<ADD-YOUR-PRIVATE-KEY-HERE>';
module.exports = {
networks: {
hyperaschain_testnet: {
provider: () => {
if (!privateKeyTest.trim()) {
throw new Error(
'Please enter a private key with funds, you can use the default one'
);
}
return new HDWalletProvider({
privateKeys: [privateKeyTest],
providerOrUrl: 'https://vayne.hyperaschain.com/'// this is RPC for testnet shard 0
});
},
network_id: 140, // testnet
},
},
};
4. Compile and deploy
truffle compile
truffle deploy --network hyperaschain_testnet