简体   繁体   English

如何修复“Truffle Migrate”字节码未定义错误

[英]How to fix 'Truffle Migrate' bytecode undefined error

Spent a few hours trying to figure this out - hoping someone has encountered this.花了几个小时试图解决这个问题 - 希望有人遇到过这个问题。 (in testing) All the testing files run. (在测试中)所有测试文件都运行。

When running truffle migrate --reset it logs the below.运行truffle migrate --reset时,它会记录以下内容。

Versions that may be useful are Truffle v5.1.58 (core: 5.1.58), Node v12.13.0 and also using pragma solidity >=0.6.0 for all smart contracts contracts.可能有用的版本是 Truffle v5.1.58(核心:5.1.58)、Node v12.13.0,并且所有智能合约合约都使用 pragma solidity >=0.6.0。

EDIT: Have tried all sorts at this point.编辑:此时已经尝试了各种方法。 Different coompilers, using solcjs and just solc - no dice.不同的编译器,使用 solcjs 而只是 solc - 没有骰子。

Compiling your contracts...
===========================
✔ Fetching solc version list from solc-bin. Attempt #1
> Compiling ./src/contracts/Exchange.sol
> Compiling ./src/contracts/Migrations.sol
> Compiling ./src/contracts/Token.sol
> Compiling openzeppelin-solidity/contracts/math/SafeMath.sol
✔ Fetching solc version list from solc-bin. Attempt #1
> Artifacts written to /Users/tony/Desktop/blockchain/el-capitan-exchange/src/abis
> Compiled successfully using:
   - solc: 0.6.12+commit.27d51765.Emscripten.clang



Starting migrations...
======================
> Network name:    'development'
> Network id:      5777
> Block gas limit: 6721975 (0x6691b7)


1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------
   > transaction hash:    0x1ce9b2b65807be1e20fcabd9e2c232ea01b64ce60f256e68749ed40a61db4392
   > Blocks: 0            Seconds: 0
   > contract address:    0x54A13cb54bD547f749a32959118cDb3E7c2b0Ee9
   > block number:        31
   > block timestamp:     1610569925
   > account:             0x4f41f50211b97527a625BbE86D9Bed6AEBD85321
   > balance:             99.77302744
   > gas used:            186951 (0x2da47)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00373902 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00373902 ETH


2_deploy_contracts.js
=====================

   Replacing 'Token'
   -----------------
   > transaction hash:    0xa7104779b88389cc116e9c9492ee26b5a6824dda7505ebb3a4860476d374cfa6
   > Blocks: 0            Seconds: 0
   > contract address:    0xC30B06Df705b2B86ebF46E61F799Ee5B0d476229
   > block number:        33
   > block timestamp:     1610569926
   > account:             0x4f41f50211b97527a625BbE86D9Bed6AEBD85321
   > balance:             99.75454758
   > gas used:            881658 (0xd73fa)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.01763316 ETH


TypeError: Cannot read property 'bytecode' of undefined
    at Deployer._preFlightCheck (/Users/tony/.nvm/versions/node/v12.13.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:173:1)
    at /Users/tony/.nvm/versions/node/v12.13.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:282:1
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Truffle v5.1.58 (core: 5.1.58)
Node v12.13.0

I just got a similar error because I had我刚遇到类似的错误,因为我有

    await deployer.deploy();

in my migration file.在我的迁移文件中。 You must enter the contract argument您必须输入合同参数

    await deployer.deploy(MyToken);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM