UnhandledPromiseRejectionWarning: Error: The contract code couldn't be stored, please check your gas limit

独自空忆成欢 提交于 2019-11-30 17:28:17

Had exactly same problem! Seems it is caused by the bug in the "truffle-hdwallet-provider" version 0.0.5. During the udemy course it was using "0.0.3" apparently.

If you do the following should be okay, it worked for me.

npm uninstall truffle-hdwallet-provider
npm install --save truffle-hdwallet-provider@0.0.3

Then I ran the same contract which has deployed successfully.

Good luck!

This issue can be solved by adding the '0x' as the prefix of the bytecode:

.deploy({ data: '0x' + bytecode, arguments: ['Hi there!'] })

More information is at https://ethereum.stackexchange.com/a/47654.

I believe bytecode is being treated as a single number rather than a series of bytes. Instead of submitting data:bytecode, try:

data:'0x0' + bytecode

it will "preserve" bytecode value as a string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!