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,740 points
836 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,350 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 30, 2018 in Blockchain by Shashank
• 10,400 points
883 views
0 votes
2 answers

Why is network already up to date while trying to deploy a contract on truffle?

I guess you have ganache running already ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,400 points
4,109 views
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,100 points

edited Aug 10, 2018 by Omkar 2,430 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,100 points
695 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
1,663 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,215 views
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
• 69,210 points
1,237 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,350 points
1,399 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,350 points
1,386 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP