gpt4 book ai didi

ethereum - 如何修复 'Truffle Migrate' 字节码未定义错误

转载 作者:行者123 更新时间:2023-12-05 06:54:01 25 4
gpt4 key购买 nike

花了几个小时试图解决这个问题 - 希望有人遇到过这个问题。 (在测试中)所有测试文件运行。

运行 truffle migrate --reset 时,它会记录以下内容。

可能有用的版本是 Truffle v5.1.58(核心:5.1.58)、Node v12.13.0 并且还对所有智能合约合约使用 pragma solidity >=0.6.0。

编辑:在这一点上已经尝试了各种方法。不同的编译器,使用 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

最佳答案

我刚刚遇到了类似的错误,因为我有

    await deployer.deploy();

在我的迁移文件中。您必须输入契约(Contract)参数

    await deployer.deploy(MyToken);

关于ethereum - 如何修复 'Truffle Migrate' 字节码未定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65653125/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com