Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raineorshine/generate-contract-factory
Generates a factory solidity contract that instantiates a contract and returns its address.
https://github.com/raineorshine/generate-contract-factory
ethereum solidity
Last synced: about 1 month ago
JSON representation
Generates a factory solidity contract that instantiates a contract and returns its address.
- Host: GitHub
- URL: https://github.com/raineorshine/generate-contract-factory
- Owner: raineorshine
- License: isc
- Created: 2016-11-20T22:26:53.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-26T03:05:04.000Z (almost 8 years ago)
- Last Synced: 2024-09-08T21:30:18.761Z (2 months ago)
- Topics: ethereum, solidity
- Language: JavaScript
- Size: 16.6 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# generate-contract-factory
[![npm version](https://img.shields.io/npm/v/generate-contract-factory.svg)](https://npmjs.org/package/generate-contract-factory)Generates a factory contract in Solidity that instantiates a given contract and returns its address. Use in combination with [generate-contract-interface](https://github.com/raineorshine/generate-contract-interface) to reduce deployment bytecode.
## Install
```sh
$ npm install --save generate-contract-factory
```## CLI Usage
```js
$ generate-contract-factory < MyContract.sol > MyContractFactory.sol
```## API Usage
```js
const generateFactory = require('generate-contract-factory')const src = `pragma solidity ^0.4.4;
contract MyContract {
uint _a;
uint _b;
function MyContract(uint a, uint b) {
_a = a;
_b = b;
}
}`console.log(generateFactory(src))
/* Output:
pragma solidity ^0.4.4;
import './MyContract.sol';
contract MyContractFactory {
function create(uint a, uint b) public returns(address) {
return address(new MyContract(a, b));
}
}
*/```
## Issues
Before reporting, please makes sure your source is parseable via [solidity-parser](https://github.com/ConsenSys/solidity-parser).
## License
ISC © [Raine Revere](https://github.com/raineorshine)