MetaCoin Demo Project
Next, clone the MetaCoin demo project, and install the dependencies:
Shell
git clone https://github.com/truffle-box/metacoin-box
cd metacoin-box
npm install @truffle/hdwallet-provider
Use your favorite editor to edit the truffle-config.js file. Replace its content with the following code snippet, which configures the Dnero local privatenet and the Mainnet.
JavaScript Code Block
Run the MetaCoin Unit Test Suite against the DNERO Local Privatenet
First, we need to setup the DNERO local privatenet with the Dnero/Ethereum RPC Adaptor following this guide.
Recall that on the Dnero blockchain, Dtoken is the gas token, similar to Ether on the Ethereum blockchain. Thus, to run the unit test cases, we first need to send Dtoken to your wallet.
Shell
truffle deploy --network Dnero_privatenet --reset
Next we can run the unit test cases (sometimes the test could take 2-3 minutes to complete):
Shell
truffle test ./test/TestMetaCoin.sol --network Dnero_privatenet
truffle test ./test/metacoin.js --network Dnero_privatenet
Deploy the MetaCoin Contract to the Dnero Mainnet
First, modify the following line in the truffle-config.js file to replace the private key with the actual private key of the deployer wallet (should delete the key after use, do NOT commit the private key to GitHub):
JavaScript
var deployerPrivateKey = '12345';
Also, make sure the deployer wallet has a sufficient amount of DToken on the DNERO Mainnet (e.g. 100 Dtoken). Next, execute the command below to deploy the smart contracts to the Dnero Mainnet. In rare cases, the command might exit with an error. If that happens, simply re-execute the deploy command.
Shell
truffle deploy --network Dnero_mainnet –reset
Last updated