I want to use a deployed contract that has been deployed through Mist using byte code.

This is how I try to get the contract using a testnet:

import contract from 'truffle-contract';
import Web3 from 'web3';

if (typeof web3 !== 'undefined') {
    web3 = new Web3(web3.currentProvider);
} else {
    // set the provider you want from Web3.providers
    web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

const existingContract = new web3.eth.Contract([
        "constant": true,
        "inputs": [],
        "name": "getNetworkAddress",
        "outputs": [
                "name": "addr",
                "type": "address"
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, ...
], "0x375b2cfB88c3732a14f2AbDD55c561E48c3ff960", { // contract address
    from: '0x749707e9327bc87fd6710de26334bd7003ca15b1', // coinbase
    gasPrice: '20000000000',
    gas: 5000000

existingContract.options.data = '0x6060604052...'; // byte code

const test = contract(existingContract);
test.deployed().then((result) => {

This gives the following error:

Error: Contract has not been deployed to detected network (network/artifact mismatch)

What am I missing?

  • Delete the comments, you have error with it. – TahaBA Dec 29 '17 at 20:59
  • I added the comments only for this post, so you can know what addresses those are. They do not cause errors in the app anyway, just tested it in reality. – jt123 Dec 29 '17 at 21:37

Your Answer

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

Browse other questions tagged or ask your own question.