Deploy contract using solcjs

+1 vote

I'm trying to deploy a contract using solcjs following that tutorial blog post https://blog.topl.me/how-to-deploy-solidity/

here is my code

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();

now when I actually run the script, the compiler send me back that error.

Error: Type "bytes32" not supported for state variable.\n mapping (address => bytes32) restaurants;\n

here is my contract code.

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;
    }
}

I am using solcjs version 0.4.4 the error doesnt depend on the node client, it happen both with geth and js-eth on the development network

Sep 26, 2018 in Blockchain by digger
• 26,550 points
53 views

1 answer to this question.

0 votes

Try to add some typo and run this:

const output = solc.compile({sources: input}, 1);
console.log(output.errors);
answered Sep 26, 2018 by slayer
• 29,050 points

Related Questions In Blockchain

0 votes
1 answer

How do i deploy a contract using bigchainDB?

Currently BigchainDB v.1.0.0 does not support Smart ...READ MORE

answered Jun 29, 2018 in Blockchain by Shashank
• 10,350 points
115 views
0 votes
2 answers
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 17,020 points

edited Aug 10, 2018 by Omkar 464 views
0 votes
1 answer

Can I swap an ERC-20 token with a Neo NEP5 token using a smart contract?

Every Blockchain has a separate administration. So, it ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,020 points
84 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
140 views
0 votes
1 answer
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 67,480 points
77 views
0 votes
1 answer

Error when trying to deploy Ethereum smart contract using web3j

Create a new credential based on the Credentials.create ...READ MORE

answered Oct 3, 2018 in Blockchain by slayer
• 29,050 points
211 views
0 votes
1 answer

How to access member functions of smart contract using web3?

I have implemented a similar feature and ...READ MORE

answered Aug 13, 2018 in Blockchain by slayer
• 29,050 points
74 views