How do I start using Gnosis with truffle in development?

I’m following the Events, Oracles and Markets tutorial https://gnosis-pm-js.readthedocs.io/en/latest/events-oracles-and-markets.html

I’ve spun up a react-truffle box but I keep getting the following error when I try and fire the ‘createDescription’ function:

Uncaught (in promise) Error: Error: Invalid JSON RPC response: “”

The docs refer to this issue here https://gnosis-pm-js.readthedocs.io/en/latest/installation.html#ganache-cli-and-private-chain-providers

The problem is that running (cd node_modules/\@gnosis.pm/pm-contracts/ && truffle migrate) just returns the following error despite truffle develop running in a separate terminal window:

Can someone please help me understand how I get @gnosis.pm to play nicely with truffle in development.

Yoo! Author of that tutorial here… >_>

You will want to have Ganache or Ganache CLI running in the background. Either spin up Ganache and make sure that the port is set to 8545, or run Ganache CLI in a separate terminal window, which defaults to listening on port 8545.

If you do have one of those running and it still doesn’t work, then maybe you have a firewall up, or some sort of ip tables configuration? Make sure that you can connect to localhost:8545. You can try to curl localhost:8545. If you get a 400 Bad Request, you’re on the right track. If you get something like curl: (7) Failed to connect to localhost port 8545: Connection refused, then your Ethereum JSON RPC provider (which in this case is Ganache, but may be a local Geth running with HTTP RPC enabled) is not receiving requests on that port.

1 Like

Thank you.

I managed to change the ganache setting to 8545.

Then if I change the port in truffle.js and line 24 on src/getWeb3.js to 8545 and migrate the project again it works.

Is there any way to do this without using Ganache and just the local testnet that truffle spins up in development?

Used this setup but having some issues with creating an oracle.
at?stream-channels=true&arg=Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn App.js:112 creating oracle... App.js:114 ipfs hash is Qme8yRqWZd5GhDcv2rs7ibvZGfF93ddXggBLVh6aggckjn contract.js:679 Uncaught (in promise) Error: CentralizedOracleFactory has no network configuration for its current network id (5777). at Function.network (contract.js:679) at Function.getter (contract.js:618) at Function.get (contract.js:700) at Function.getter (contract.js:615) at formatCallSignature (utils.js:570) at new TransactionError (utils.js:585) at _callee3$ (utils.js:167)

Is there any way to do this without using Ganache and just the local testnet that truffle spins up in development?

Not yet… I’m currently working on that :wink:

EDIT: Actually, if you are referring to truffle develop, since that starts a test chain listening on port 9545, you could just make sure that the contracts are migrated wrt that chain, the artifacts on which the migration information is recorded is included in your build, and then it works as usual, though that approach isn’t any easier than just using Ganache.

1 Like

You’re using network ID 5777? Did you migrate on the same network with the same ID?

Figured it out. It was a migration issue. thanks @alanlu Alan