https://github.com/augmint/abiniser
Truffle post processor to generate FE readable files
https://github.com/augmint/abiniser
abi ethereum ethereum-contract ethereum-dapp truffle truffle-post-processor
Last synced: about 1 month ago
JSON representation
Truffle post processor to generate FE readable files
- Host: GitHub
- URL: https://github.com/augmint/abiniser
- Owner: Augmint
- License: mit
- Created: 2018-04-23T09:25:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-16T12:01:21.000Z (over 3 years ago)
- Last Synced: 2025-03-02T17:04:43.721Z (over 1 year ago)
- Topics: abi, ethereum, ethereum-contract, ethereum-dapp, truffle, truffle-post-processor
- Language: JavaScript
- Size: 109 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Abiniser
Truffle post processor to generate and maintain ABI and deployments files for FE use. Abiniser aims to address the shortcoming of truffle-contract json format which can't handle multiple deployments of same contract source file and can't manage multiple ABI versions.
Abiniser works on files generated by truffle and its output keeps track of abi version and deployments on different networks.
Abineser's abi and deployment files output is intended to be added to repository so it can be used by front end code.
It's an alpha implementation, being tested on [Augmint](https://github.com/Augmint) projects. Expect breaking changes (e.g. output format changes) even with minor version bumps.
# Usage
## Install
```
$ npm -g install abiniser
```
## Workflow
Each time your abis changed or a new deployment (to any network) done abiniser should be run. It will automatically create new abi file version (based on abi hash) and will add new entries to deployment files.
These can be safely checked in
TODO: more description on the workflow
## Run
```
$ abiniser -h
Usage: abiniser [options] [command]
Truffle post processor to generate ABI and deployment repository files
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
generate|gen [options] Generate deployment and abi files from Truffle generated JSON files
removeSourceEntries|removeSrc [options] remove source entries from all deployment files
check [options] Basic integrity check of files generated. Checks references between Abi files and deployment files
More info: https://github.com/Augmint/abiniser
Examples:
abiniser generate
Creates abi and deployments jsons from all truffle contract json files listed in abiniser.json config file
```
###Generate deploy and abi files
```
$abiniser generate -h
Usage: generate|gen [options]
Generate deployment and abi files from Truffle generated JSON files
Options:
-c, --config-file [value] Sets abiniser config file. (default: "./abiniser.json")
-a, --abi-output-dir [value] Sets abi output directory. (default: "./abiniser/abis")
-d, --deployments-output-dir [value] Sets deployments output directory. (default: "./abiniser/deployments")
-n, --network-id [value] Generate deployments file only for the given network id number
-i, --input-dir [value] Sets input directory with truffle contract json files. (default: "./build/contracts")
-r, --regenerate Regenerate abi and deploy files even if they exists with same abi hash
-s, --source-include Include contract source in generated deploy file
-h, --help output usage information
```
Create `abiniser.json` file with the list of contract files to work on:
```
{
"truffleContractFiles": ["Contract1.json", "Contract2.json"]
}
```
You can set command line options in `abiniser.json` too.
# Output format
## Abi files
One file per contract and abi version is generated:
`abiniser/abis/_.json`
Each file contains the contract's Abi in [Solidity ABI JSON format](https://solidity.readthedocs.io/en/develop/abi-spec.html#abi-json).
## Deployment files
`abiniser/deployments//_DEPLOYS.json` files:
```
{
"contractName": "",
"latestAbiHash": "7fde219f…",
"deployedAbis": {
"7fde219f…": {
"latestDeployedAddress": "7fde219f…",
"deployments": {
"7fde219f…": {
"generatedAt": "",
"truffleContractFileUpdatedAt": "",
"deployTransactionHash": "0x12…",
"compiler": {
"name": "solc",
"version": "0.4.23"
},
"sourceHash": "7fde219f…",
"bytecodeHash": "a454e8ba…",
"deployedBytecodeHash": "55abcee…",
"source": ""
}
"0xab444b...": {…}
}
},
"a454e8ba… ": {
"latestDeployedAddress": "a9de219f…",
"deployments": {…}
}
}
}
```
## Maintenance features
### Checks on generated files
```
$ abiniser check -h
Usage: check [options]
Basic integrity check of files generated. Checks references between Abi files and deployment files
Options:
-a, --abi-output-dir [value] Sets abi output directory to work on. (default: "./abiniser/abis")
-d, --deployments-output-dir [value] Sets deployments output directory to work on. (default: "./abiniser/deployments")
-h, --help output usage information
```
### Remove all source entries from deploy files already generated by abiniser
```
$ abiniser removeSourceEntries -h
Usage: removeSourceEntries|removeSrc [options]
remove source entries from all deployment files
Options:
-d, --deployments-output-dir [value] Sets deployments output directory to work on. (default: "./abiniser/deployments")
-h, --help output usage information
```
## Contribution
Issue reports, feature suggestions and PRs are more than welcome.
## Authors
### Initial version
- concept: [phraktle](https://github.com/phraktle) & [szerintedmi](https://github.com/szerintedmi)
- [szerintedmi](https://github.com/szerintedmi)
Check the whole team on [augmint.org](https://www.augmint.org)
## Licence
This project is licensed under the MIT license - see the [LICENSE](LICENSE) file for details.