2
我嘗試使用下面該教程的博客文章https://blog.topl.me/how-to-deploy-solidity/部署使用合同solcjs
這裏solcjs部署合同是我的代碼
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();
現在,當我實際運行腳本,編譯器給我回到那個錯誤。
Error: Type "bytes32" not supported for state variable.\n mapping (address => bytes32) restaurants;\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發展網絡