truffle初始化的项目在部署(migrate)的时候出现invalid opcode的异常

在使用Truffle和Ganache开发以太坊智能合约时遇到部署异常'invalid opcode'。问题源于Truffle内置的Solidity编译器可能产生的opcode不被EVM接受。通过自定义Solidity编译器,注释掉truffle-config.js中的相关配置,并利用外部编译器进行编译,解决了此问题。

异常重现

最近在使用truffle框架与Ganache开发以太坊合约的时候,采用默认配置的时候(仅修改端口为7545),部署时会出现invalid opcode异常如下图:
异常截图

项目初始化

通过命令truffle unbox webpack进行项目初始化
项目目录如下:
项目目录

配置文件truffle-config.js详情

/**
 * Use this file to configure your truffle project. It's seeded with some
 * common settings for different networks and features like migrations,
 * compilation and testing. Uncomment the ones you need or modify
 * them to suit your project as necessary.
 *
 * More information about configuration can be found at:
 *
 * truffleframework.com/docs/advanced/configuration
 *
 * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
 * to sign your transactions before they're sent to a remote public node. Infura accounts
 * are available for free at: infura.io/register.
 *
 * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
 * public/private key pairs. If you're publishing your code to GitHub make sure you load this
 * phrase from a file you've .gitignored so it doesn't accidentally become public.
 *
 */

// const HDWallet = require('truffle-hdwallet-provider');
// const infuraKey = "fj4jll3k.....";
//
// const fs = require('fs');
// const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
   
   
  /**
   * N
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值