Deploy contracts using Truffle
This article takes Pet-Shop as an example to introduce how to deploy smart contract into smartBCH chain using truffle.
Please note in the following example we assume you are using a local single-node testnet. Instead, if you want to use a remote node to provide JSON-RPC, just replace “localhost” with the node’s IP address.
Start smartBCH single testing node
Please flow this doc to start smartBCH single testing node. When the testing node is started with default options, it will serve JSON-RPC on localhost:8485. You can use the following cmd to see if node works well:
You can also use this public test node (deployed by smartBCH community) if you do not want to deploy your local node:
Install Truffle
You 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:
And run the following cmd the see if truffle was installed successfully:
Clone Pet-Shop
Using [direction]git[/direction] [direction]clone[/direction] cmd to clone pet-shop source code into you local directory:
Modify truffle-config.js, change development network port to match your local node (e.g. 8545):
You can modify truffle-config.js further and add a network config like this if your want to use greyh’s test node too:
Do not forget to [direction] install [/direction] web3 through npm install cmd if you use public test node: