Created
January 21, 2016 17:00
-
-
Save ddaws/9b8eb54ebc8a87c115e2 to your computer and use it in GitHub Desktop.
Gulp compile Solidity
This file contains 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
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