Skip to content

Instantly share code, notes, and snippets.

@ddaws
Created January 21, 2016 17:00
Show Gist options
  • Save ddaws/9b8eb54ebc8a87c115e2 to your computer and use it in GitHub Desktop.
Save ddaws/9b8eb54ebc8a87c115e2 to your computer and use it in GitHub Desktop.
Gulp compile Solidity
var Web3 = require("web3");
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
var Requidity = require('requidity'), requidity = new Requidity(web3);
PuddingGenerator = require("ether-pudding/generator");
gulp.task('contracts:deploy', (cb) => {
requidity('./contracts/MyContract.sol').then((compiled) => {
var MyContract = web3.eth.contract(compiled.MyContract.info.abiDefinition);
MyContract.new(..., {
data: compiled.MyContract.code,
from: web3.eth.coinbase,
gas: 3000000
}, function (error, contract) {
if (error) {
console.error('Error deploying contract : ' + err);
} else if (!contract.address) {
console.log('Transaction hash : ' + contract.transactionHash);
} else {
console.log('Contract address : ' + contract.address);
// save the contract
PuddingGenerator.save({
"MyContract": {
abi: compiled.MyContract.info.abiDefinition,
binary: compiled.MyContract.code,
address: contract.address
}
}, 'contracts');
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment