Skip to content

Instantly share code, notes, and snippets.

@industral
Last active May 2, 2019 15:18
Show Gist options
  • Save industral/16760065d5492c11107a462a1c3cdad3 to your computer and use it in GitHub Desktop.
Save industral/16760065d5492c11107a462a1c3cdad3 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const ganache = require('ganache-cli');
const Web3 = require('web3');
const solc = require('solc');
const web3 = new Web3(ganache.provider());
(async function() {
const input = {
language: 'Solidity',
sources: {
'Inbox.sol': {
content: fs.readFileSync('./Inbox.sol').toString()
}
},
settings: {
outputSelection: {
'*': {
'*': ['*']
}
}
}
};
const output = JSON.parse(solc.compile(JSON.stringify(input)));
const contract = output.contracts['Inbox.sol'].Inbox;
const accounts = await web3.eth.getAccounts();
const contractInstance = new web3.eth.Contract(contract.abi);
const inbox = await contractInstance.deploy({
data: contract.evm.bytecode.object,
arguments: ["Test"]
}).send({from: accounts[0], gas: 1000000});
console.log(inbox);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment