HDWalletProvider engine.stop() p = HDWalletProvider(MNEMONIC_SYSTEM, "http://ganache:8545", 0); p.engine.stop(); HDWalletProvider engine.stop() and pool export function GetHdProvider(id: number, rpcurl: string) { //return new HDWalletProvider(MNEMONIC_SYSTEM, url, id); return id==0?Provider1Pool.acquire():Provider2Pool.acquire(); } // Normal use const hdProvider0 = await GetHdProvider(0, providerUrl).then(function(client) {return client}).catch(function(err) {throw new HttpException(err.toString(), HttpStatus.BAD_REQUEST);}); const hdProvider1 = await GetHdProvider(1, providerUrl).then(function(client) {return client}).catch(function(err) {throw new HttpException(err.toString(), HttpStatus.BAD_REQUEST);}); // Normal release ReleaseHDProvider1(hdProvider1 ); // Pool code const genericPool = require("generic-pool"); const opts = { max: 10, // maximum size of the pool min: 2, // minimum size of the pool idleTimeoutMillis: 30000, log: true }; const factory0 = { // maybe different parms create: function() { return new HDWalletProvider(MNEMONIC_SYSTEM, RPCURL, 0); }, destroy: function(client) { client.
What this Error? Example:
transaction A get nonce 1
transaction B get nonce 2
transaction C get nonce 3
But blockchain package B、C first, then package A. If happen this step, get error.
With truffle? Because
Normal
const wallet = new HDWalletProvider(mnemonic, url, id); const AContract = new TruffleContract(Json_contract); AContract.setProvider(wallet); wallet.addresses[] AContract. use contract api Sometime you call contract “set/write” api two times.
Example:
Create contract first. Write data into contract second.