MY ChainList.sol code

pragma solidity ^0.4.23;

contract ChainList  {

  struct  data  {
    uint   ownernumber;
    uint   id;

  uint value;
  mapping (uint256 => data) public  datamatching;

  function storedata (uint _ownernumber, uint _id) public {
    var  persondata  = datamatching[value];
    persondata .ownernumber = _ownernumber;
    persondata. id  =  _id;

  function getData(uint256 userId) returns (uint, uint){
    return (datamatching[userId].ownernumber, datamatching[userId].id);

// deploying contract in using migrations

var ChainList = artifacts.require("./Migrations.sol");

module.exports = function (deployer) {

// My trufle.js code

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id

i am have deployed succefully

Compiling ./contracts/ChainList.sol...
Compiling ./contracts/Migrations.sol...

Compilation warnings encountered:


home/mdvenkatesh/Desktop/asset/contracts/ChainList.sol:14:5: Warning: Use of the "var" keyword is deprecated.
    var  persondata  = datamatching[value];
,/home/mdvenkatesh/Desktop/asset/contracts/Migrations.sol:11:3: Warning: Defining constructors as functions with the same name as the contract is deprecated. Use "constructor(...) { ... }" instead.

**Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x942947d411cc40c214ee717f12a8626033aea99b9db0cfda2189a8c214c0d068
  Migrations: 0x4d838fd69456fcb2c4c49b1b05c8ae7b7205cde5
Saving successful migration to network...
  ... 0x20659b7fdf1ac7c4a1899be68938297b5fb1cae318024c61eee7886d007d134d
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Replacing Migrations...
  ... 0xe287e9ccbe891349ca0a2b1bac64a1291558b3817a6689431bf88721122eb7c1
  Migrations: 0xcc3979c6af9f5003445f26e5c1dfdc140bba29c5
Saving successful migration to network...
  ... 0x2a3b60f8cf3571ef12bb81ea5c80d22b6e2febae8e38f2dd0c05e0f147137305
Saving artifacts...**

Now I am trying to intract with truffle i am getting the following error

ChainList.deployed().then(function(instance){app= instance });

Error: ChainList has not been deployed to detected network (network/artifact mismatch)
    at /usr/lib/node_modules/truffle/build/webpack:/packages/truffle-contract/contract.js:454:1

I Think I followed all steps but i don't know what went wrong please help me

  • did you configure truffle to use your network, I mean in your JS code. can you add your entire js code or a gist link ? – Kaki Master Of Time Oct 1 '18 at 10:45
  • Check this ethereum.stackexchange.com/questions/45559/… and first fix the var error and try again. Also note that the constructor is defined differently now. Fix these first and try again – R.D Oct 1 '18 at 10:45

You have messed up your deployment scripts. In the end you should have 2 files in your /migrations/ folder:

  1. 1_initial_migration.js

    var Migrations = artifacts.require("./Migrations.sol");
    module.exports = function(deployer) {
  2. 2_deploy_contracts.js

    var ChainList = artifacts.require("/path/to/ChainList.sol");
    module.exports = function (deployer) {

In your example, you changed the migration variables to "ChainList", but you still point to ./Migrations.sol. Simply change this to point to your contract file instead.

  • Thanks , I have deployed successfully my contract but my function is not working as I expected i taught get function will give all the ids of my parent but it is not happining plese help me to create a function which gets all the id's that are linked to my parent id – Venkatesh Muthyala Oct 1 '18 at 11:35
  • You should open a new question with clear examples of what you expect for a given input and output. – Shawn Tabrizi Oct 1 '18 at 11:48

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.