I am running a private network and would like to use truffle-contract
to interact with the contracts. Unfortunately it gives me this error:
Error: Contract has not been deployed to detected network (network/artifact mismatch)
I am using truffle-contract@3.0.7
and here is how I set up my code:
const Web3 = require('web3-quorum');
const truffleContract = require('truffle-contract');
const web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:22000'));
const ContractJSON = require('./build/contracts/Contract.json');
var MyContract = truffleContract({
abi: ContractJSON.abi,
unlinked_binary: ContractJSON.bin,
address: ContractJSON.address
});
MyContract.setProvider(web3.currentProvider);
MyContract.deployed().then(function(instance) {
return instance.myMethod(
web3.utils.toHex('31ad646cf39d485d8df7'),
Number(100),
Number(12345));
}).then(function(result) {
console.log(result);
}).catch(err => { console.log(err); });
I also tried MyContract.setNetwork(10);
, whereby 10 matches net.version
output (geth console) or also chainId in the genesis.json. Unfortunately without luck.
var MyContract = truffleContract(ContractJSON)
. – Ismael Jan 21 at 4:35