{"id":25420217,"url":"https://github.com/dl-solarity/hardhat-gobind","last_synced_at":"2025-07-08T01:10:21.523Z","repository":{"id":65142773,"uuid":"580017196","full_name":"dl-solarity/hardhat-gobind","owner":"dl-solarity","description":"Hardhat plugin to generate Go bindings","archived":false,"fork":false,"pushed_at":"2025-05-24T21:55:44.000Z","size":15928,"stargazers_count":28,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-24T23:22:23.789Z","etag":null,"topics":["bind","go","hardhat","hardhat-plugin","solarity"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@solarity/hardhat-gobind","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dl-solarity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-12-19T14:10:40.000Z","updated_at":"2025-05-24T21:55:47.000Z","dependencies_parsed_at":"2025-05-24T23:17:39.299Z","dependency_job_id":"3da20ce0-d16e-4de4-855a-cfccf6e1012f","html_url":"https://github.com/dl-solarity/hardhat-gobind","commit_stats":null,"previous_names":["dl-solarity/hardhat-gobind","dl-solidity-library/hardhat-gobind"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/dl-solarity/hardhat-gobind","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dl-solarity%2Fhardhat-gobind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dl-solarity%2Fhardhat-gobind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dl-solarity%2Fhardhat-gobind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dl-solarity%2Fhardhat-gobind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dl-solarity","download_url":"https://codeload.github.com/dl-solarity/hardhat-gobind/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dl-solarity%2Fhardhat-gobind/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262545181,"owners_count":23326688,"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":["bind","go","hardhat","hardhat-plugin","solarity"],"created_at":"2025-02-16T19:36:27.123Z","updated_at":"2025-07-08T01:10:21.516Z","avatar_url":"https://github.com/dl-solarity.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/v/@solarity/hardhat-gobind.svg)](https://www.npmjs.com/package/@solarity/hardhat-gobind) [![hardhat](https://hardhat.org/buidler-plugin-badge.svg?1)](https://hardhat.org)\n\n# Hardhat GoBind\n\n[Hardhat](https://hardhat.org) plugin to simplify generation of smart contract bindings for Golang.\n\n## What\n\nThis plugin helps you generate `.go` files with bindings to call smart contracts from Go code. To produce them, the plugin uses `abigen` in a `wasm` binary form that is built from [go-ethereum/cmd/abigen](https://github.com/ethereum/go-ethereum/tree/master/cmd/abigen) Go module.\n\n## Installation\n\n```bash\nnpm install --save-dev @solarity/hardhat-gobind\n```\n\nAdd the following statement to your `hardhat.config.js`:\n\n```js\nrequire(\"@solarity/hardhat-gobind\")\n```\n\nOr, if you are using TypeScript, add this to your `hardhat.config.ts`:\n\n```ts\nimport \"@solarity/hardhat-gobind\"\n```\n\n## Tasks\n\nThe bindings generation can be run either with built-in `compile` or the provided `gobind` task.\n\nTo view the available options, run these help commands:\n\n```bash\nnpx hardhat help compile\nnpx hardhat help gobind\n```\n\n## Environment extensions\n\nThis plugin does not extend the environment.\n\n## Usage\n\nThe plugin works out of the box: `npx hardhat gobind` will compile and generate bindings for all the contracts used in the project into the default folder.\n\nTo generate the most recent bindings, clean old artifacts with `npx hardhat clean` beforehand.\n\n### Configuration\n\nThe default configuration looks as follows. You may customize all fields in your *hardhat config* file.\n\n```js\nmodule.exports = {\n  gobind: {\n    outdir: \"./generated-types/bindings\",\n    deployable: false,\n    runOnCompile: false,\n    abigenVersion: \"v1\",\n    verbose: false,\n    onlyFiles: [],\n    skipFiles: [],\n  },\n}\n```\n\n- `outdir` : The directory where the generated bindings will be placed\n- `deployable` : Generates the bindings with the bytecode (makes them deployable within Go)\n- `runOnCompile` : Whether to run bindings generation on compilation\n- `abigenVersion`: The version of abigen to use (v1 or v2)\n- `verbose`: Detailed logging on generation (e.g. count of included and skipped contracts, source paths, names)\n- `onlyFiles`: If specified, bindings will be generated **only for matching** sources, other will be ignored\n- `skipFiles`: Bindings will not be generated for **any matching** sources, also if those match `onlyFiles`\n\nSome of the parameters are only available in CLI and they override the ones defined in your *hardhat config* (e.g. `--deployable` will generate deploy method regardless of `config.gobind.deployable` value). Run `npx hardhat help gobind` to get available options.\n\n### Including/excluding files\n\n- Path stands for relative path from project root to either `.sol` file or directory.\n- If path is a directory, all its files and sub-directories are considered matching.\n- If source is a node module, `node_modules` must not be present in the path.\n\n## How it works\n\nThe plugin runs `compile` task (if `--no-compile` is not given), gets the artifacts from *Hardhat Runtime Environment* (HRE), filters them according to `onlyFiles` and `skipFiles`, and performs the following actions:\n\n1. Writes contract's ABI (and bytecode, if necessary) into a temporary file `ContractName.abi` (and `ContractName.bin` with bytecode).\n2. Derives destination folder from the original file location: if the file is in `./contracts`, the folder will be `./your_outdir/contracts`.\n3. Derives Go package name from the parent folder: for `./your_outdir/nested/My_Contracts` it will be `mycontracts`.\n4. Depending on the presence of `--v2` flag, it calls `abigen` or `abigen v2` via WebAssembly: `abigen `(`--v2`)` --abi /path/to/file.abi --pkg packagename --type ContractName --out /path/to/your_project/your_outdir` (and `--bin /path/to/file.bin`, if necessary).\n5. Removes temporary files.\n\n\nBindings are generated for contracts, not files. Having 3 contracts in a single file, you get 3 `.go` files named after contracts. If you skip the file, all 3 contracts are ignored.\n\nConsider we have Hardhat project with the following structure (excluding some files for brevity):\n\n```\n.\n├── contracts\n│   ├── Example.sol\n│   ├── Sample.sol\n│   └── interfaces\n│       ├── IExample.sol\n│       └── ISample.sol\n├── hardhat.config.ts\n└── node_modules\n    └── @openzeppelin\n        └── contracts\n            └── access\n                ├── Ownable\n                │   └── Ownable.sol\n                └── Ownable2Step\n                    └── Ownable2Step.sol\n```\n\n`npx hardhat gobind` with the default configuration will create the following directory structure. Note there are no `node_modules` parent directory for `@openzeppelin` dependency.\n\n```\ngenerated-types\n└── bindings\n    ├── @openzeppelin\n    │   └── contracts\n    │       └── access\n    │           ├── ownable\n    │           │   └── Ownable.go\n    │           └── ownable2step\n    │               └── Ownable2Step.go\n    │          \n    └── contracts\n        ├── example\n        │   └── Example.go\n        ├── sample\n        │   └── Sample.go\n        └── interfaces\n            ├── iexample\n            │   └── IExample.go\n            └── isample\n                └── ISample.go\n```\n\nIn most cases, you want bindings only for your `contracts/` directory, excluding `contracts/interfaces` and all the dependencies from `node_modules`.\n\nIt is achieved by adding the following into your *hardhat config*:\n\n```js\nonlyFiles: [\"contracts\"],\nskipFiles: [\"contracts/interfaces\", \"@openzeppelin\", \"@solarity\"],\n```\n\n## Known limitations\n\n- `--verbose` is not available in CLI because of names clash with Hardhat. [Learn more](https://hardhat.org/hardhat-runner/docs/errors#HH202).\n- `node_modules` must not be present in the path.\n- All environment variables are omitted when the abigen.wasm is called\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdl-solarity%2Fhardhat-gobind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdl-solarity%2Fhardhat-gobind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdl-solarity%2Fhardhat-gobind/lists"}