@abstract-money/cli
The Abstract CLI is a command-line tool for generating JavaScript bindings to contracts that use Abstract.
Installation
npm i @abstract-money/cli
Usage
abstract <command> [options]
Init
Once you have installed the CLI, you need to define the CLI config in abstract.config.ts
.
You can generate a default configuration using the command:
abstract init
This will generate an abstract.config.ts
in your project root. You can then configure it according to your needs.
Configuration
Here's an example of how to configure abstract.config.ts
:
import { defineConfig } from '@abstract-money/cli'
import { react, registry, vanilla } from '@abstract-money/cli/plugins'
export default defineConfig({
// Target directory for generated files.
out: './src/generated',
// Define contracts for which to generate bindings
// Use this for contracts not registered in the Abstract schemas repository
contracts: [
{
name: "exampleAdapter",
path: "../contracts/exampleAdapter/schema/",
namespace: "your-namespace",
version: "0.1.0",
moduleType: "adapter", // Specify this if it's an adapter module
},
// You can add more contracts here as needed
],
// List of plugins to use.
plugins: [
// Generate React hooks.
react(),
// Pull contract schemas from the registry at https://github.com/AbstractSDK/schemas
registry({
contracts: [
{
name: 'app-name', // Your App Name.
namespace: 'abstract', // To claim a namespace on mainnet, please get in touch with Abstract Team.
version: '0.1.0',
},
],
}),
// Generate vanilla JavaScript bindings
vanilla({
// Enable Abstract App features for specific contracts
enableAbstractAppFor: ['exampleAdapter']
}),
],
})
Generating for Contracts Not Registered in Schemas Repository
Example:
contracts: [
{
name: "exampleAdapter",
path: "../contracts/exampleAdapter/schema/",
namespace: "your-namespace",
version: "0.1.0",
moduleType: "adapter",
},
],
Generating for Contracts from the Abstract Registry
Example:
registry({
contracts: [
{
name: 'payment-app',
namespace: 'abstract',
version: '0.0.1',
},
],
}),
You can find the latest versions of these contracts in the Abstract schemas repository.
Enabling Abstract App Features
If you're working with an Abstract app, use the vanilla
plugin with the enableAbstractAppFor
option.
Example:
vanilla({
enableAbstractAppFor: ['exampleAdapter']
}),
Generate
Once done, you're ready to generate the code:
abstract generate
You can use additional options as mentioned above. You should get an output like:
❯ abstract generate
✔ Validating plugins
✔ Resolving contracts
✔ Validating contracts
✔ Running plugins
✔ Writing to src/generated/index.ts
And you should be all set to use the types generated directly into your codebase.