Navigation Menu

Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Run error #9

Open
LeopoldoD opened this issue Jul 13, 2017 · 21 comments
Open

Run error #9

LeopoldoD opened this issue Jul 13, 2017 · 21 comments

Comments

@LeopoldoD
Copy link

I have just downloaded the React-auth-box and followed all the steps. I'm using testrpc for testing. However, I'm getting the following errors while doing truffle test:

  1. Error: VM Exception while processing transaction: invalid opcode
  2. Error: SimpleStorage has not been deployed to detected network (network/artifact mismatch)

I'm getting a similar error while testing the webpack server:

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

Testrpc appears to be connected to my dApp, but at the end displays the following error:
Transaction: 0xe54ab4cc933946de26a0176ac25c3a4e79ab752efa006054bdd4b30fb5a74d3f
Gas usage: 4712388
Block Number: 76
Block Time: Thu Jul 13 2017 13:12:02 GMT+0200 (CEST)
Runtime Error: invalid opcode

Any help is appreaciated. Thanks.

Leopoldo.

@appjitsu
Copy link

appjitsu commented Aug 17, 2017

Yep. Same here...

Compilation and migration seem to work fine: ie, no errors until you try to browse to the login view or click the signup button.

Browser console says:

MetaMask - injected web3
inpage.js:85 MetaMask: web3 will be deprecated in the near future in favor of the ethereumProvider 
https://github.com/ethereum/mist/releases/tag/v0.9.0
get @ inpage.js:85
getWeb3.js:27 Injected web3 detected.
index.js:25 Web3 initialized!
contract.js:419 Uncaught (in promise) Error: Authentication has not been deployed to detected network (network/artifact mismatch)
    at contract.js:419
    at <anonymous>

@chunkzer
Copy link

chunkzer commented Oct 6, 2017

Same here. Anywords on workaround or fixes to this issue?

@inzmamulhassan
Copy link

Facing same issue Any solution??

@LeopoldoD
Copy link
Author

have you guys deployed their contracts to the network (testrpc, geth etc.)?

  • truffle migrate

@LeopoldoD
Copy link
Author

Recommendations:

  • Check Metamask status (pointing out to port 8545)
  • Reset migrations ("truffle migrate --reset")

@inzmamulhassan
Copy link

did that.. but still getting the same error,. Tried multiple times now downloaded the Box again and again repeat the process described.

turffle develop
compile
migrate

but still the same result
testrpc is running

so is MetaMask

@LeopoldoD
Copy link
Author

are your contracts deployed to the network? Some lines should appear in testrpc indicating the contracts are successfully deployed. For example:
Transaction: 0x7403cc1ce6bb29264732e5d677e8b3c2f96cbba039736ddd14eb9e4a3c09be89
Contract created: 0x6f9379db54985b6d25da140dd7c41a8d6e50f579
Gas usage: 160259
Block Number: 113
Block Time: Tue Nov 14 2017 10:54:48 GMT+0100 (CET)

eth_newBlockFilter
eth_getFilterChanges
eth_getTransactionReceipt
eth_getCode
eth_uninstallFilter
eth_sendTransaction

Transaction: 0x852bcf6d883e9a67edd80c0f20cadd48b1b0d24a166b83ae33aad62c59041bb3
Contract created: 0xf973bd1e79097099a97602329b73c12cefccb928
Gas usage: 2322314
Block Number: 114
Block Time: Tue Nov 14 2017 10:54:48 GMT+0100 (CET)

eth_newBlockFilter
eth_getFilterChanges
eth_getTransactionReceipt
eth_getCode
eth_uninstallFilter
eth_sendTransaction

Transaction: 0x3b8f451221b223d155b9afab59800c0d6018a444dea00371260f9641201ed2dd
Gas usage: 26798
Block Number: 115
Block Time: Tue Nov 14 2017 10:54:48 GMT+0100 (CET)

@inzmamulhassan
Copy link

inzmamulhassan commented Nov 14, 2017

Actually no these lines are not comming in testrpc.

i have also tried

migrate --reset as well

@LeopoldoD
Copy link
Author

Then your contracts are not deployed to testrpc, therefore, you can not interact with them.
Make sure Metamask is listening to the same port as testrpc is running (default port 8545).

@inzmamulhassan
Copy link

When i use migrate without
truffle develop

this is the result

inzamam@inzamam-Lenovo-ideapad-110-15ISK:~/Documents/truffle-webpack$ truffle migrate --reset
Using network 'development'.

Running migration: 1_initial_migration.js
Deploying Migrations...
... undefined
Error encountered, bailing. Network state unknown. Review successful transactions manually.
Error: Error: Exceeds block gas limit
at StateManager.queueTransaction (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:84915:21)
at GethApiDouble.eth_sendTransaction (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:84423:14)
at GethApiDouble.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:84222:10)
at next (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:53732:18)
at GethDefaults.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:84119:12)
at next (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:53732:18)
at FilterSubprovider.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:60186:7)
at next (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:53732:18)
at DelayedBlockFilter.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:83947:3)
at next (/usr/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:53732:18)
at Object.InvalidResponse (/usr/lib/node_modules/truffle/build/cli.bundled.js:43303:16)
at /usr/lib/node_modules/truffle/build/cli.bundled.js:331156:36
at /usr/lib/node_modules/truffle/build/cli.bundled.js:175492:11
at /usr/lib/node_modules/truffle/build/cli.bundled.js:314196:9
at XMLHttpRequest.request.onreadystatechange (/usr/lib/node_modules/truffle/build/cli.bundled.js:315621:13)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/lib/node_modules/truffle/build/cli.bundled.js:70159:18)
at XMLHttpRequest._setReadyState (/usr/lib/node_modules/truffle/build/cli.bundled.js:70449:12)
at XMLHttpRequest._onHttpResponseEnd (/usr/lib/node_modules/truffle/build/cli.bundled.js:70604:12)
at IncomingMessage. (/usr/lib/node_modules/truffle/build/cli.bundled.js:70564:24)
at emitNone (events.js:91:20)

@LeopoldoD
Copy link
Author

Are you running the standard contracts from truffle box or have you added your own contracts?

@inzmamulhassan
Copy link

Standard contracts of truffle Boxes ,. without any editing

@inzmamulhassan
Copy link

BTW my testrpc account 0 balance in MetaMask

@LeopoldoD
Copy link
Author

I have not faced this issue, perhaps review this link. Your Metamask balance should be 100 for each testrpc account (by default), try importing a different private key in Metamask.

@inzmamulhassan
Copy link

@LeopoldoD here is the screen shot where i am stuck

https://ibb.co/kM7n3G

@LeopoldoD
Copy link
Author

Ok, you are using the default Metamask account. You need to import a new account:

  • From testrpc, copy the first private key. The list of public and private keys are provided when you run testrpc.
  • From Metamask select the man symbol (upper right side).
  • Select import account.
  • Paste the private key from testrpc.
  • A new account should appear showing a balance of 100 ether.

@nekifirus
Copy link

nekifirus commented Nov 23, 2017

Same issue. I don't understand why metamask needed. Truffle box. Follow instructions.

npm install -g truffle

truffle unbox react-auth

then

truffle develop

In truffle console:

Truffle Develop started at http://localhost:9545/

Accounts: 
...etc

compile

Compiling ./contracts/Authentication.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/zeppelin/lifecycle/Killable.sol...
Compiling ./contracts/zeppelin/ownership/Ownable.sol...

Compilation warnings encountered:

/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/ownership/Ownable.sol:13:3: Warning: No visibility specified. Defaulting to "public".
  function Ownable() {
  ^
Spanning multiple lines.
,/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/ownership/Ownable.sol:22:3: Warning: No visibility specified. Defaulting to "public".
  function transferOwnership(address newOwner) onlyOwner {
  ^
Spanning multiple lines.
,/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/lifecycle/Killable.sol:12:3: Warning: No visibility specified. Defaulting to "public".
  function kill() onlyOwner {
  ^
Spanning multiple lines.

Writing artifacts to ./build/contracts

migrate

truffle(develop)> migrate
Using network 'develop'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x61e607486b82312dba3f46fb87e101d9ce7e0caf326096c77407d4ad5d71e406
  Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
  ... 0xd7bc86d31bee32fa3988f1c1eabce403a1b5d570340a3a9cdba53a472ee8c956
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying Ownable...
  ... 0x603ca1809d3ef52b8550c74e1da351c138e277d738092320fbf5ad6c8c73915f
  Ownable: 0x345ca3e014aaf5dca488057592ee47305d9b3e10
  Deploying Killable...
  ... 0x8b052a316b4144605d054fec9e2a855e1f45e668d17ccb059aaf902b396138eb
  Killable: 0xf25186b5081ff5ce73482ad761db0eb0d25abfbf
  Deploying Authentication...
  ... 0x4c440077bcf12a3bfe1018c01f1ae13b5b2bf0771039a5064e27fec1465fd88f
  Authentication: 0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f
Saving successful migration to network...
  ... 0x0faca9f680c3dbf3e6d41c8695e44a8a3c27184f28d4d0eebaa633ea51b8736d
Saving artifacts...

After this in another console:

npm run start

Compiled successfully!

The app is running at:

  http://localhost:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

Open http://localhost:3000/. See the page. Press 'SingUp'. Enter name. In browser console:

Injected web3 detected.
index.js:25 Web3 initialized!
contract.js:419 Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)
    at contract.js:419
    at <anonymous>

Click "Login". In browser console:

contract.js:419 Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)
    at contract.js:419
    at <anonymous>

In truffle develop console:

test

truffle(develop)> test
Using network 'develop'.

Compiling ./contracts/Authentication.sol...
Compiling ./contracts/zeppelin/lifecycle/Killable.sol...
Compiling ./contracts/zeppelin/ownership/Ownable.sol...
Compiling ./test/TestAuthentication.sol...
Compiling truffle/Assert.sol...
Compiling truffle/DeployedAddresses.sol...

Compilation warnings encountered:

/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/ownership/Ownable.sol:13:3: Warning: No visibility specified. Defaulting to "public".
  function Ownable() {
  ^
Spanning multiple lines.
,/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/ownership/Ownable.sol:22:3: Warning: No visibility specified. Defaulting to "public".
  function transferOwnership(address newOwner) onlyOwner {
  ^
Spanning multiple lines.
,/Users/Nekifirus/node/Projects/ethnews/truffle-box/contracts/zeppelin/lifecycle/Killable.sol:12:3: Warning: No visibility specified. Defaulting to "public".
  function kill() onlyOwner {
  ^
Spanning multiple lines.
,/Users/Nekifirus/node/Projects/ethnews/truffle-box/test/TestAuthentication.sol:9:3: Warning: No visibility specified. Defaulting to "public".
  function testUserCanSignUpAndLogin() {
  ^
Spanning multiple lines.



  TestAuthentication
    ✓ testUserCanSignUpAndLogin (84ms)

  Contract: Authentication
    ✓ ...should sign up and log in a user. (98ms)


  2 passing (589ms)


@aquaflamingo
Copy link

+1 still struggling with this.

@ctapang
Copy link

ctapang commented Dec 6, 2017

At least in my case, the contracts are being deployed twice. There is an auto-migrate that runs with "truffle test", and it fails. The command "truffle deploy:contracts" works, but the auto-migrate doesn't. So what I did to fix the issue was to modify the migration scripts: before calling deployer.deploy() or .new(), check first whether that particular contract has already been successfully deployed, and don't deploy again if already deployed. I use .isDeployed() to determine if it is already deployed, and if so call .deployed() instead of deployer.deploy().

@Squall949
Copy link

Squall949 commented Dec 22, 2017

Hi @nekifirus , for this issue

contract.js:419 Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)

In my case, I found out it was caused by the chrome extension of MetaMask, which resulted in getting wrong network_id.

After I disabled the extension, the result was correct as expected. truffle-box/react-box#33

Updated:
We can set up Metamask with Truffle Develop (truffle 4 above) for local test.
http://truffleframework.com/docs/advanced/truffle-with-metamask

@ashok-kumar
Copy link

In my case it solved by updating proper network_id in config files.

  • After starting testrpc, get the network id by using following command.(paste following command in new terminal window)
    curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[]}' http://localhost:8545
  • It will give you following response. Here 'result' will be the network id
    {"jsonrpc":"2.0","result":"1519215457240"}
  • Update the network id in config files - truffle.js or truffle-config.js

Credits: https://ethereum.stackexchange.com

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants