如何解决我在运行我为 Solidity 项目制作的 deploy.js 文件时遇到了 assert.js:383 抛出错误我应该怎么办?
这里是终端输出
[sohampadia@localhost inBox]$ node deploy.js
assert.js:383
throw err;
^
AssertionError [ERR_ASSERTION]: Invalid callback object specified.
at runWithCallbacks(/home/sohampadia/solidityprojs/inBox/node_modules/solc/wrapper.js:97:7)
at compileStandard(/home/sohampadia/solidityprojs/inBox/node_modules/solc/wrapper.js:207:14)
at Object.compileStandardWrapper [as compile] (/home/sohampadia/solidityprojs/inBox/node_modules/solc/wrapper.js:214:14)
at Object.<anonymous> (/home/sohampadia/solidityprojs/inBox/compile.js:8:23)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/sohampadia/solidityprojs/inBox/deploy.js:3:33)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
generatedMessage: false,code: 'ERR_ASSERTION',actual: false,expected: true,operator: '=='
}**
详情-
- npm --version 6.14.12
- mocha@8.3.2
- ganache-cli@6.12.2
- web3 // 最新版本
如果您想了解更多详情,我很乐意为您提供。
pragma solidity ^0.4.17;
contract InBox{
string public message;
function InBox(string initialMessage) public {
message=initialMessage;
}
function setMessage(string newMessage) public{
message=newMessage;
}
}
const HDWalletProvider = require('@truffle/hdwallet-provider');
const Web3 = require('web3');
const { interface,bytecode } = require('./compile');
const provider = new HDWalletProvider(
'apple apple apple apple apple apple apple apple apple bee bee
bee','https://rinkeby.infura.io/v3/qwertyuiopasbdhne'
);
const web3 = new Web3(provider);
const deploy = async () => {
const accounts = await web3.eth.getAccounts();
console.log('Attempting to deploy from account',accounts[0]);
const result = await new web3.eth.Contract(JSON.parse(interface))
.deploy({ data: bytecode,arguments: ['Hi there!'] })
.send({ gas: '1000000',from: accounts[0] });
console.log('Contract deployed to',result.options.address);
};
deploy();
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const inBoxPath = path.resolve(__dirname,'contracts','InBox.sol');
const source = fs.readFileSync(inBoxPath,'utf-8');
module.exports = solc.compile(source,1).contracts[':InBox'];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。