当尝试使用 solc-js 编译智能合约时,我收到错误
Krishna:投票 krishnakankipati$ Node 部署.js
编译契约(Contract)
断言.js:350
抛出错误; ^
断言错误 [ERR_ASSERTION]:指定的回调无效。
let compilerInput = {
'Voter': fs.readFileSync('Voter.sol', 'utf8')
};
console.log('Compiling the contract')
// Compile and optimize the contract
let compiledContract = solc.compile(compilerInput, 1);
// Get compiled contract
let contract = compiledContract.contracts['Voter:Voter'] // Voter contract from Voter file.
// Save contract's ABI
let abi = contract.interface;
fs.writeFileSync('abi.json', abi);
最佳答案
您没有正确使用 solc-js。您需要对输入进行字符串化,并且传递 1 而不是导入回调。请在发布问题之前阅读文档:https://github.com/ethereum/solc-js
考虑使用 etherjs,比 web3 更好的文档和更强大的功能。
关于node.js - 在以太坊部署智能合约时出现错误如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53953260/