← All tools

@codama/cli

Popularity 65 Updated Development & Build

A CLI for setting up and managing Codama IDLs

npmauto-collected

Installation

npm
npm install -g @codama/cli

Install with npm.

Codama

[npm-downloads-image]: https://img.shields.io/npm/dm/codama.svg?style=flat [npm-image]: https://img.shields.io/npm/v/codama.svg?style=flat [npm-url]: https://www.npmjs.com/package/codama [ci-image]: https://img.shields.io/github/actions/workflow/status/codama-idl/codama/main.yml?logo=GitHub [ci-url]: https://github.com/codama-idl/codama/actions/workflows/main.yml

Codama is a tool that describes any Solana program in a standardised format called a Codama IDL.

A Codama IDL can be used to:

  • ✨ Generate program clients in various languages and frameworks.
  • 📚 Generate documentation and tooling for your programs.
  • 🗃️ Register your IDL for others to discover and index.
  • 🔭 Provide valuable information to explorers and wallets.

Table of contents

  • Getting started. Install and use Codama in your project.
  • Coming from Anchor. Have an Anchor IDL instead? Let’s make that work.
  • Codama scripts. Enrich your Codama config file with more scripts.
  • Available visitors. See what’s available for you to use.
  • Getting a Codama IDL. Extract Codama IDLs from any program.
  • Codama’s architecture. A bit more on the node/visitor design.
  • Other resources.

Getting started

Installation

To get started with Codama, simply install codama to your project and run the init command like so:

pnpm install codama
codama init

You will be prompted for the path of your IDL and asked to select any script presets you would like to use. This will create a Codama configuration file at the root of your project.

Usage

You may then use the codama run command to execute any script defined in your configuration file.

codama run --all # Run all Codama scripts.
codama run js    # Generates a JavaScript client.
codama run rust  # Generates a Rust client.

Coming from Anchor

If you are using Anchor or Shank macros, then you should already have an Anchor IDL. To make it work with Codama, you simply need to provide the path to your Anchor IDL in your Codama configuration file. Codama will automatically identify this as an Anchor IDL and will convert it to a Codama IDL before executing your scripts.