Deployed Contracts have no Network when using async/await
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
When my contracts are deployed using the truffle migrate --reset
command, none of them have a network in the contract JSON even though the contracts are deployed. This causes the unit tests to fail saying the contract hasn’t been deployed to the network.
This only happens with the contracts I’m working on as it works fine with different solidity projects.
I’ve tested the contracts in question on Remix and they deploy fine.
Steps to Reproduce
truffle migrate --reset
truffle test
Expected Behavior
- Contract has network assigned in JSON
- Can test against the contract
Actual Results
- Contract is deployed after a successful migration:
Running migration: 1_initial_migration.js
Replacing Migrations...
... 0xf893631620cee218dfdac5a5b118e950b39c411add85ccf5ce0891abc594b451
Migrations: 0x01afadc80ac64129f3100633b556f1a40a15a9c0
Saving successful migration to network...
... 0x0af95e5b3d45c4b37b56287395f0815b4e315d5b3a5bdc0bdcdc5134e444aeb4
Saving artifacts...
Running migration: 2_deploy_linkpool.js
Replacing Arithmetic...
... 0x5667313901deae25a423b2f5c9bc5554ef691491bf1d8d7cd8e71d40948f416d
Arithmetic: 0x9a3be86baaf7b84f60860b7be146963f5bc8a21b
Saving successful migration to network...
Deploying PoolStorageLocator...
... 0x6ed6122d0851c169df7d156341845ca884e232d455b91825a7e495196d54d6ae
Saving artifacts...
... 0x19ca0c89a2c079c8f7dd1c44db88e3520c4ac3781f907db58480e364a31d812f
PoolStorageLocator: 0xaed391873b70b273393ffc8cce46cfa34aeedc03
Deploying Node...
... 0xbc09e15f761c95071533db92a3900bcdfdac68762bfde30abfa23e89a6434748
Node: 0xd17e00d08da375b61a10d36a25fb20fde1c8bc29
Deploying LinkPool...
... 0xb6f889a1d8a8b9bd04fc8ecbdf58e58dac33dc014e940c266e15d6e2b181d050
LinkPool: 0x02961e046dfa5ed124013dac3893cc88af45d371
Deploying PoolStorage...
... 0x2906e140275cab2ffb22d3198070ab325b1796daef5a18e935719d7d8fb3fb95
PoolStorage: 0xd8962788087a931eee12512267a5263ece988091
... 0xe302b366dae309610d063a7bb3748e951fb1d7159ca496b82a29e6d27f26ed4c
Running step...
- JSON of contract (Bulk of contract redacted):
"compiler": {
"name": "solc",
"version": "0.4.18+commit.9cf6e910.Emscripten.clang"
},
"networks": {},
"schemaVersion": "1.0.1",
"updatedAt": "2017-12-12T21:49:28.535Z"
- Result of unit test:
1) Contract: LinkPool "before each" hook for "should add a node":
Error: LinkPool has not been deployed to detected network (network/artifact mismatch)
at /usr/lib/node_modules/truffle/build/cli.bundled.js:318327:17
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Environment
- Operating System: Windows 10 Pro Insider Preview 1709
- Truffle version: Truffle v4.0.1 (core: 4.0.1), Solidity v0.4.18 (solc-js)
- Ethereum client: Ganache CLI v6.0.3 (ganache-core: 2.0.2) (Same happens with testrpc, geth)
- node version: 8.9.3
- npm version: 5.6.0
ℹ️ I can provide access to the repo where the contracts are stored. I’m reluctant to publicly post the source of them until they’re ready.
Issue Analytics
- State:
- Created 6 years ago
- Comments:29 (11 by maintainers)
Top Results From Across the Web
contract not deployed to detected network - Ethereum Stack ...
The issue is that deployer doesn't handle well Promises/async behavior you have to ensure all contracts are deployed before the deploy script ...
Read more >Truffle contract interaction with async await - Stack Overflow
I am using nodejs v.8.15.0 and truffle v4.1.15. I have deployed a contract and I can also interact with it, but not the...
Read more >Testing Your Smart Contracts With JavaScript (Including ...
Testing Your Smart Contracts With JavaScript (Including Async/Await Promises) ... such as making sure the contracts are deployed before running the tests.
Read more >Writing solidity contract tests in javascript - Truffle documentation
Note: If you're unfamiliar with writing unit tests in Mocha, ... Because Truffle has no way of detecting which contracts you'll need to...
Read more >ethcontract - Rust - Docs.rs
Generate bindings for Ethereum smart contracts. Internally, the generated types use `web3` crate to interact with the Ethereum network and uses a custom ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue needs to be reopened, as the behavior of smart contracts deployment is different when using ES7 async/await syntax, which is totally unexpected. The latest version of Truffle still has this issue.
Is there a reason for this? Is it a bug or intended behavior? I’m experiencing this issue, except that I deploy my contracts across multiple migration scripts; the workaround effectively makes me put everything in one migration script. I’m running Truffle v4.0.5.
EDIT: Even that doesn’t work. I get the same issue; Truffle prints out the addresses of the relevant contracts, but still doesn’t store them in the JSON. Running ContractName.deployed() from the console gives the network/artifact mismatch stuff.