trufflesuite/drizzle-legacy

Contract not found on network ID

Xuefeng-Zhu opened this issue ยท 14 comments

With example in https://github.com/truffle-box/drizzle-box, after deploy the contract and start the client, it gave error for not finding contract.

image

Experienced issue the same. Solved by downgrading web3js version, from 1.0.0-beta.40 to 1.0.0-beta.37.

In your project directory (where node_modules dir) type:

npm i web3@1.0.0-beta.37

Thanks @khssnv ! I've tried beta38, 39, 40 and 41 and indeed 37 is the latest one working. I've submitted a PR to fix this temporarily.

Closing this for now. We've pinned the version of web3 to beta.35. If this is still occurring, please reopen.

Still running into the same issue for both beta.35 and beta.37. Please revisit the issue.

Try to set the custom RPC on metamask to http://localhost:9454.

I got a similar error and this is what I did:

  1. npm i web3@1.0.0-beta.37 in my client folder (where react is running)
  2. Open Ganache and run truffle console instead of truffle develop
  3. Reinstall Metamask
  4. Add a new "custom RPC" in Metamask with the configuration of Ganache
  5. Change Metamask to the custom rpc
  6. Restart the React App


Screenshot from 2019-07-22 11-11-24

I am getting this error, I have tried 1.0.0-beta.37 and 1.0.0-beta.35

I've revisited the issue and fixed a port number issue with the Truffle box here: truffle-box/drizzle-box@ebaee38

Please try again and let me know if you have issues.

My port number was already 8545. I am attaching major portions of code -

My contract Storage.sol -

pragma solidity ^0.5.0;
contract Storage {
  string public data;

  function getData() view external returns(string memory) {
    return data;
  }

  function setData(string calldata _data) external{
    data=_data;
  }
}

My drizzleOptions.js

import Storage from './contracts/Storage.json';
const options={
    contracts:[Storage],
    web3:{
        fallback:{
            type:"ws",
            url:"ws://127.0.0.1.8545",
        },
    }
};

export default options;

My Container.js -

import React, { Component} from 'react';
import {drizzleConnect} from 'drizzle-react';

const mapStateToProps=state =>({state}); 

class Container extends Component{

render(){
    console.log(this.props);
    return (<div>Storage</div>);
}
}

export default drizzleConnect(Container , mapStateToProps);

MyComponent.js

import React from 'react';
import {AccountData, ContractData, ContractForm} from 'drizzle-react-components';


const MyComponent = () =>(
    <div>
    <h2>Bal of first account</h2>
      <AccountData accountIndex ={0} units={"ether"} precision={3}/>

    <h2>Get Data</h2>
    <ContractData contract="Storage" method="getData" />

    <h2>Set Data</h2>
    <ContractForm contract="Storage" method="setData" labels={['new value of `data`']}/>

    </div>
);

export default MyComponent;

@nehaagarwal0719 And you are certain that your MetaMask is set to http://127.0.0.1:8545? Have you tried running without MetaMask (i.e. in incognito mode)? I'm going to need a reproduction repo from you if you want me to debug this with you.

@adrianmcli ,yes, my metamask is running on 8545. I would be thankful if you could see my code here - https://github.com/nehaagarwal0719/Drizzle-React/tree/master

@adrianmcli ,yes, my metamask is running on 8545. I would be thankful if you could see my code here - https://github.com/nehaagarwal0719/Drizzle-React/tree/master

Try to follow my last comment. Thats the way I fix that error.

@ceskmcfran I tried the same but it doesn't work for me.

@nehaagarwal0719 Looks like you have a typo here: https://github.com/nehaagarwal0719/Drizzle-React/blob/master/app/src/drizzleOptions.js#L7

Instead of:

ws://127.0.0.1.8545

It should be:

ws://127.0.0.1:8545

Note the use of a colon (:) instead of a period (.).