Ethereum 使用solcjs部署契约
在教程的博客文章之后,我正在尝试使用solcjs部署一个契约 这是我的密码Ethereum 使用solcjs部署契约,ethereum,solidity,Ethereum,Solidity,在教程的博客文章之后,我正在尝试使用solcjs部署一个契约 这是我的密码 const web3 = new Web3(); web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545")); async function compileAndDeploy() { let ambrosiaContract; try { let contract = await fs.readF
const web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
async function compileAndDeploy() {
let ambrosiaContract;
try {
let contract = await fs.readFileSync( path.join(__dirname, './Ambrosia.sol') );
let Ambrosia = contract.toString();
let input = {};
input[ path.join(__dirname, './Ambrosia.sol')] = Ambrosia;
console.log('> Compiling Storage');
let output = solc.compile({sources: input}, 1);
console.log(output.contracts, output.formal);
ambrosiaContract = output.contracts['Ambrosia'];
}
catch (e) {
console.log(e);
}
console.log('deploying...')
let ambrosiaInstance = await deployStorage(ambrosiaContract)
console.log('...deployed at ' + ambrosiaInstance.address)
}
compileAndDeploy();
现在,当我实际运行脚本时,编译器会将该错误发回给我
错误:状态变量不支持键入“bytes32”。\n映射
(地址=>bytes32)餐厅\n
这是我的合同代码
pragma solidity ^0.4.4;
contract Ambrosia {
mapping (address => bytes32) restaurants;
address _owner;
event Transfer(address indexed _from, address indexed _to, uint256 _value); // listen to that event whenever a transfer has been made..
event Order(address indexed _from, address indexed _to, uint256 _value); // listen to that event whenever an order is triggered
function Ambrosia() {
_owner = msg.sender;
}
}
我使用的是solcjs版本0.4.4
错误不依赖于节点客户端,它发生在开发网络上的geth和js eth上此错误来自Solidity。到目前为止,它不支持Solidity的大部分功能,所以您可以随意忽略它们 实际编译错误在
输出中返回。错误数组。尝试添加一些输入错误并运行以下命令:
const output = solc.compile({sources: input}, 1);
console.log(output.errors);