truffle-box / react-auth-box

Truffle, Webpack, React, Redux boilerplate with routing and authentication via a smart contract.
https://truffle-box.github.io/
MIT License
176 stars 66 forks source link

Run error #9

Open LeopoldoD opened 7 years ago

LeopoldoD commented 7 years ago

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:

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 commented 7 years ago

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 commented 6 years ago

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

inzmamulhassan commented 6 years ago

Facing same issue Any solution??

LeopoldoD commented 6 years ago

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

LeopoldoD commented 6 years ago

Recommendations:

inzmamulhassan commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Actually no these lines are not comming in testrpc.

i have also tried

migrate --reset as well

LeopoldoD commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

inzmamulhassan commented 6 years ago

Standard contracts of truffle Boxes ,. without any editing

inzmamulhassan commented 6 years ago

BTW my testrpc account 0 balance in MetaMask

LeopoldoD commented 6 years ago

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 commented 6 years ago

@LeopoldoD here is the screen shot where i am stuck

https://ibb.co/kM7n3G

LeopoldoD commented 6 years ago

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

nekifirus commented 6 years ago

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 commented 6 years ago

+1 still struggling with this.

ctapang commented 6 years ago

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 commented 6 years ago

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. https://github.com/truffle-box/react-box/issues/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 commented 6 years ago

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

Credits: https://ethereum.stackexchange.com