0.2.2 • Published 8 years ago
requidity v0.2.2
requidity
A require system for importing and compiling solidity contracts.
var Web3 = require('web3'), web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
var Requidity = require('requidity'), requidity = new Requidity(web3);
// async
requidity('./contracts/greeter.sol').then((compiledContract) => {
// do something awesome!
});
// async multiple
requidity(['./contracts/greeter.sol', './contracts/token.sol']).then((compiledContracts) => {
// now you have an array of compiled contracts!
});
// or sync ... if you really want to ...
var otherCompiledContract = requidity('./contracts/token.sol').sync();
Why?
previously I would :
var solc = require('solc'),
fs = require('fs');
fs.readFile('path/to/contract.sol', (err, buffer) => {
if (err) throw err;
compiledContracts = web3.eth.compile.solidity(buffer.toString());
});
or worse :
var Web3 = require('web3'),
fs = require('fs');
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
fs.readFile('path/to/contract.sol', (err, buffer) => {
if (err) throw err;
compiledContracts = solc.compile(buffer.toString());
});
and now its as simple as requidity('some/contract.sol')
:)
Installing
npm install requidity
;)
Authors
- Dawson Reid dreid93@gmail.com