Truffle
Truffle is supported via Janus and there are two ways to get it working.
By loading private keys into Janus/Qtum
Using
@qtumproject/hdwallet-provider
Lets unbox an example truffle box and walk through running a migration
First, go to an empty directory and create a new directory and unbox
mkdir react-box
cd react-box
truffle unbox qtumproject/react-boxOutput should look like this
Starting unbox...
=================
✔ Preparing to download box
✔ Downloading
✔ Cleaning up temporary files
✔ Setting up box
Unbox successful, sweet!
Commands:
Compile: truffle compile
Migrate: truffle migrate
Test contracts: truffle test
Test dapp: cd client && npm test
Run dev server: cd client && npm run start
Build for production: cd client && npm run buildNext, install dependencies
Generating a BIP44 mnemonic to use with truffle
You can use Mnemonic Code Converter to generate a mnemonic for local development
if you plan on using this tool for mainnet, you can download a release and run it completely offline.
And then lets take a look at the truffle-config.js file
Here, you will need to copy your mnemonic into the regtest mnemonic space
Launching Janus/Qtum
Seeding regtest with Qtum
You can get your address from the truffle console once Qtum is running.
Then you can seed regtest using either qtum-cli or Janus
note that fromhexaddress requires dropping the hex prefix 0x
Qtum block rewards need to be at least 2000 blocks old to be used
Or you can use dev_generatetoaddress Janus RPC call to do this
note that generating this many blocks will cause Janus to timeout waiting for a response from Qtum, but Qtum will still generate the blocks
truffle migrate
Now that your local regtest environment has Qtum we can deploy code with truffle
Artifacts will be in build/contracts/*.json
Last updated