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(''));

const ContractJSON = require('./build/contracts/Contract.json');

var MyContract = truffleContract({
    abi: ContractJSON.abi,
    unlinked_binary: ContractJSON.bin,
    address: ContractJSON.address

MyContract.deployed().then(function(instance) {  
    return instance.myMethod(
}).then(function(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.

  • 1
    Can you try passing the whole artifact file to truffleContract, ie something like var MyContract = truffleContract(ContractJSON).
    – Ismael
    Jan 21 '19 at 4:35

Passing the whole artifact file to truffleContract make it work, ie something like

const ContractJSON = require('./build/contracts/Contract.json');
var MyContract = truffleContract(ContractJSON)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.