Last active
May 2, 2019 15:18
-
-
Save industral/16760065d5492c11107a462a1c3cdad3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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