{"id":20117944,"url":"https://github.com/tokenchain/cxgenenzymes","last_synced_at":"2026-05-12T00:46:47.654Z","repository":{"id":57218307,"uuid":"418401528","full_name":"tokenchain/cxgenenzymes","owner":"tokenchain","description":"Tool to convert and building compiled programing for Solidity","archived":false,"fork":false,"pushed_at":"2021-10-18T10:06:39.000Z","size":53280,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T20:07:44.104Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tokenchain.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.json","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-18T08:00:41.000Z","updated_at":"2021-10-18T10:06:42.000Z","dependencies_parsed_at":"2022-08-28T21:40:58.702Z","dependency_job_id":null,"html_url":"https://github.com/tokenchain/cxgenenzymes","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokenchain%2Fcxgenenzymes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokenchain%2Fcxgenenzymes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokenchain%2Fcxgenenzymes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tokenchain%2Fcxgenenzymes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tokenchain","download_url":"https://codeload.github.com/tokenchain/cxgenenzymes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241564434,"owners_count":19982958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T19:08:58.051Z","updated_at":"2025-11-29T00:04:44.135Z","avatar_url":"https://github.com/tokenchain.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CX Gen Enzymes for Solidity\n\n\nThis package allows you to generate TypeScript or Python contract wrappers from ABI files.\nIt's heavily inspired by [Geth abigen](https://github.com/ethereum/go-ethereum/wiki/Native-DApps:-Go-bindings-to-Ethereum-contracts) but takes a different approach.\nYou can write your custom handlebars templates which will allow you to seamlessly integrate the generated code into your existing codebase with existing conventions.\n\n[Here](https://github.com/0xProject/0x-monorepo/tree/development/packages/0x.js/abi-gen-templates) are the templates used to generate the contract wrappers used by 0x.js.\n\n## Installation\n\n`cnpm i -g easy-abi-gen` from China\n\n`npm i -g easy-abi-gen` from the rest of the world\n\n\n## Template supports in working progress:\n\n- [x] Typescript\n- [x] Python\n- [ ] Golang\n- [ ] Php\n- [ ] Rust\n- [ ] Java\n- [ ] Swift\n- [ ] Bash\n\n## Usage\n\n```\n$ abi-gen-uni --help\nOptions:\n  --help               Show help                                       [boolean]\n  --version            Show version number                             [boolean]\n  --abibins            Glob pattern to search for ABI JSON files that comes with with abi and bin.\n                                                             [string] [required]\n  --output, -o, --out  Folder where to put the output files  [string] [required]\n  --partials           Glob pattern for the partial template files      [string]\n  --template           Path for the main template file that will be used to\n                       generate each contract                [string] [required]\n  --backend            The backing Ethereum library your app uses. For\n                       TypeScript, either 'web3' or 'ethers'. Ethers\n                       auto-converts small ints to numbers whereas Web3 doesn't.\n                       For Python, the only possibility is Web3.py\n                          [string] [choices: \"web3\", \"ethers\"] [default: \"web3\"]\n  --network-id         ID of the network where contract ABIs are nested in\n                       artifacts                          [number] [default: 50]\n  --language           Language of output file to generate\n              [string] [choices: \"TypeScript\", \"Python\"] [default: \"TypeScript\"]\n\nExamples:\n  abi-gen-uni --abis 'src/artifacts/**/*.json'  Full usage example\n  --out 'src/contracts/generated/'\n  --partials\n  'src/templates/partials/**/*.handlebars'\n  --template\n  'src/templates/contract.handlebars'\n\n```\n\nSample Implemenation:\n```\n#!/usr/bin/env bash\n\ntypescriptabi0x() {\n  mkdir -p $COMPILED_TS\n  mkdir -p $COMPILED_PY\n\n  abi-gen-uni --abis $COMPILED_ABI \\\n    --out \"$COMPILED_TS\" \\\n    --partials \"$BUILDPATH/abi_templates/TypeScript/partials/*.handlebars\" \\\n    --template \"$BUILDPATH/abi_templates/TypeScript/contract.handlebars\"\n\n  abi-gen-uni --abis $COMPILED_ABI  \\\n   --out \"$COMPILED_PY\" \\\n   --partials \"$BUILDPATH/abi_templates/Python/partials/*.handlebars\" \\\n   --template \"$BUILDPATH/abi_templates/Python/contract.handlebars\"\n\n}\n\ntypescriptabi() {\n  abi-gen-uni ts -i $COMPILED_ABI -o $COMPILED_TS --verbose\n  mkdir -p $GEN_DOC\n  soldocgen $GEN_DOC $BUILDPATH/vault/tokenization\n}\n\n\nBUILDPATH=$HOME/to/my/workspace\nCOMPILE_FILE=\"to/my/specific.sol\"\nSOLCPATH=\"/root/contracts/vault\"\n\nGEN_DOC=\"$BUILDPATH/doc\"\nCOMPILED_ABI=\"$BUILDPATH/build/specific.abi\"\nCOMPILED_TS=\"$BUILDPATH/abi_src/gen_ts/\"\nCOMPILED_PY=\"$BUILDPATH/abi_src/gen_py/\"\nCOMPILED_HANDLERBARS=\"$COMPILED_TS/contract.handlebars\"\n\ntypescriptabi\n\n```\n\n\n\nYou're required to pass a [glob](\u003chttps://en.wikipedia.org/wiki/Glob_(programming)\u003e) template where your abi files are located.\nTL;DR - here is the example from 0x.js.\n\n`--abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry).json`\n\nWe could've just used `--abis 'src/artifacts/*.json` but we wanted to exclude some of the abi files.\n\nThe abi file should be either a [Truffle](http://truffleframework.com/) contract artifact (a JSON object with an abi key) or a JSON abi array.\n\nYou need to also specify the location of your main template used for every contract `--template` as well as the partial templates `--partials` that can later be used from the main one.\n\n## How to write custom templates?\n\nThe best way to get started is to copy [0x.js templates](https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen-templates) and start adjusting them for your needs.\nWe use [handlebars](http://handlebarsjs.com/) template engine under the hood.\nYou need to have a master template called `contract.mustache`. it will be used to generate each contract wrapper. Although - you don't need and probably shouldn't write all your logic in a single template file. You can write [partial templates](http://handlebarsjs.com/partials.html) and as long as they are within a partials folder - they will be registered and available.\n\n## Which data/context do I get in my templates?\n\nFor now you don't get much on top of methods abi, some useful helpers and a contract name because it was enough for our use-case, but if you need something else - create a PR.\nSee the [type definition](https://github.com/0xProject/0x-monorepo/tree/development/packages/abi-gen/src/types.ts) of what we pass to the render method.\n\n## Output files\n\nOutput files will be generated within the specified output folder. If you already have some files in that folder they will be overwritten.\n\nNames of files, classes and methods will be converted to the standard naming conventions for the given target language.\n\n## Contributing\n\nWe welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.\n\nPlease read our [contribution guidelines](../../CONTRIBUTING.md) before getting started.\n\n### Install dependencies\n\nIf you don't have yarn workspaces enabled (Yarn \u003c v1.0) - enable them:\n\n```bash\nyarn config set workspaces-experimental true\n```\n\nThen install dependencies\n\n```bash\nyarn install\n```\n\nYou will also need to have Python 3 installed in order to build and run the tests of the command-line interface, which is integrated with the `yarn build`, `yarn test`, and `yarn lint` commands described below. More specifically, your local `pip` should resolve to the Python 3 version of `pip`, not a Python 2.x version.\n\n### Build\n\nTo build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:\n\n```bash\nPKG=easy-abi-gen yarn build\n```\n\nOr continuously rebuild on change:\n\n```bash\nPKG=easy-abi-gen yarn watch\n```\n\n### Clean\n\n```bash\nyarn clean\n```\n\n### Lint\n\n```bash\nyarn lint\n```\n\n### CLI tests\n\nThe files in `test-cli/` are used to test the output generated by running the command-line tool against a set of fixture contracts. These tests are integrated with `yarn build`, `yarn test`, etc, but can be run independently per the instructions below.\n\nCompile fixture contracts:\n\n```\nyarn compile:sol\n```\n\nCompiling the fixture contracts into ABI is done ahead of time, and the ABI is checked in to `git`, in order to speed up test run time. Therefore, this compilation does not happen automatically as part of `yarn build`, and must be run explicitly after making any changes to the fixture contracts; and, any proposed changes to the fixture contracts should be accompanied by changes to the corresponding compilation artifacts.\n\nGenerate wrappers (and build them, in the case of TypeScript), and build unit tests:\n\n```\nyarn test_cli:build\n```\n\nRun unit tests and check diffs of generated wrappers vs known wrappers:\n\n```\nyarn test_cli\n```\n\nKnown-good wrappers have been previously committed and are kept in `test-cli/expected-output/{language}`. They are intended to provide sample output and should be kept in sync with the generating code. When making changes to this project or `@0x/abi-gen-templates`, run `yarn test_cli:prebuild` to generate fresh code into `test-cli/output/{language}`, and then manually copy it to `test-cli/expected-output/{language}`.\n\nRun linters against generated code:\n\n```\nyarn test_cli:lint\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokenchain%2Fcxgenenzymes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftokenchain%2Fcxgenenzymes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftokenchain%2Fcxgenenzymes/lists"}