How to fix 'Truffle Migrate' bytecode undefined error

Viewed 721

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.

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.

EDIT: Have tried all sorts at this point. Different coompilers, using solcjs and just solc - no dice.

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
1 Answers

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);
Related