2016-11-04 32 views
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发展网络

回答

1

此错误是由密实度formal verification tool上发生两者。现在它不支持大部分Solidity的功能,所以你可以自由地忽略它们。

实际编译错误返回​​数组。尝试添加一些错字并运行此:

const output = solc.compile({sources: input}, 1); 
console.log(output.errors);