This article takes Pet-Shop as an example to introduce how to deploy smart contract into smartBCH testnet using truffle.
Build smartbchd and generate a test key
Please flow this document to clone and build smartbchd. We need a test account and associated private key, smartbchd provides a sub-command to generate them for us:
$cdpath/to/your/smartbch/dir# and build smartbchd following the given doc$./smartbchdgen-test-keys-n1--show-address
The output looks like this (the generated private key and address are seperated by a space):
We need to install Node.js first, here are detailed information about how to install it on various platforms. Then, run the following cmd to install truffle:
$npminstall-gtruffle
And run the following cmd the see if truffle was installed successfully:
Using git clone cmd to clone pet-shop source code into you local directory:
Install truffle hdwallet-provider v1.2.6 (for some unknown reason, the latest version v1.3.x may not work with private keys, so we use v1.2.x here):
Modify truffle-config.js, add smartBCH testnet network configuration using you test key like bellow (you can find more smartBCH testnet RPC URLs here):
Deploy Pet-Shop to smartBCH testnet
In directory pet-shop-tutorial, using truffle migrate cmd to deploy Pet-Shop contract into smartBCH testnet:
The output looks like this:
Wow! You have deployed Pet-Shop into smartBCH testnet. Thank you for testing smartBCH testnet π