Generate bindings with the CLI

Build a typed-ABI tarball with gma generate.

CLI

gma generate reads your contract artifacts and produces a typed-ABI npm package (currently target: viem) as a .tgz tarball under output (default ./gma-out). It runs entirely on your machine and does not require a GitMyABI account.

Typical flow

gma init                  # one-time, creates gma.config.json
forge build               # or: npx hardhat compile
gma generate              # writes ./gma-out/<name>-<version>.tgz

Source frameworks

  • Foundry. Reads compiled artifacts; *.t.sol and *.s.sol are filtered out automatically.
  • Hardhat. Reads compiled artifacts after npx hardhat compile.
  • Raw ABIs. With --framework abis, pass --abis or set abis in the config to a list of files, directories, or globs.

Flags

  • --framework <auto|foundry|hardhat|abis> — defaults to auto.
  • --abis <paths> — comma-separated list of files, directories, or globs.
  • --out <dir> — override the output directory.
  • --package-name <name>, --package-version <version>, --project-name <name> — override metadata.
  • --target <viem> — codegen target (currently viem).
  • --include-empty-abis — keep contracts whose ABI is empty (interfaces, libraries).
  • --generate-mcp — also emit a companion MCP server package (stdio transport, depends on the bindings package). The codegen package is currently a preview release.
  • --mcp-allow-writes — include write tools in the MCP server (the default is read-only).
  • --publish, --registry <url>, --token <token>, --access <public|restricted>, --tag <tag>, --dry-run — publish the generated tarball in one step (see gma publish for the underlying behavior).
  • --profile <name> — profile name used to read saved registry / npm credentials.

Output

A successful run prints the resolved package name, version, and tarball path under output. When --generate-mcp is set, the companion MCP package is written alongside it and printed on a second line.

One-shot generate and publish

gma generate --publish \
  --registry https://registry.npmjs.org \
  --token "$NPM_TOKEN"

With --publish, the CLI uploads the generated tarball after building it. Use --dry-run to print what would happen without contacting the registry.

Related