Acton
Command reference

acton wrapper

Reference manual for the acton wrapper command

Synopsis

acton wrapper [options] contract-name

Description

Generate a wrapper for the contract identified by _contract-name_ from Acton.toml.

Wrapper generation uses the ABI emitted by the Tolk compiler. In practice, the contract header is the source of truth for typed storage accessors, incoming message helpers, and generated get-method bindings.

The command can also generate a stub test file or emit a TypeScript wrapper for frontend and tooling integrations.

acton wrapper compiles the selected contract directly. A prior acton build run is not required.

Options

Wrapper Options

<contract-name>

Contract name from Acton.toml to generate the wrapper for.

-o,--output<path>

Write the generated wrapper to an exact path.

Conflicts with:

--output-dir.

--output-dir<dir>

Write the generated wrapper to a directory and let Acton choose the file name.

Conflicts with:

--output.

Test Stub Options

-t,--test

Generate a stub test file together with the wrapper.

--test-output<path>

Write the generated test file to an exact path.

Requires --test.

--test-output-dir<dir>

Write the generated test file to a directory and let Acton choose the file name.

Requires --test and conflicts with --test-output.

TypeScript Options

--ts

Generate a TypeScript wrapper through gen-typescript-from-tolk.

Conflicts with:

test stub generation.

Display Options

--color<when>

Control when to use colored output.

Possible values:

auto, always, never

Project Options

--manifest-path<path>

Path to the Acton.toml file to use for this invocation.

Use this when running the command outside the project directory or when the manifest lives at a non-default location.

--project-root<path>

Path to the project root to use for configuration discovery and relative defaults.

This conflicts with --manifest-path.

ABI Requirements

Wrapper generation depends on the contract ABI exposed by the Tolk compiler.

  • storage: ... enables typed storage helpers such as fromStorage
  • incomingMessages: ... enables send{Message} helpers
  • declared get methods are emitted as wrapper methods

If incomingMessages is missing, message-sending helpers are not generated. If storage is missing, storage helpers fall back to an untyped initializer.

TypeScript Generation

acton wrapper --ts shells out to npx gen-typescript-from-tolk-dev.

  • Node.js, npm, and npx must be available in PATH
  • existing wrapper files at the target path are overwritten
  • --ts cannot be combined with --test, --test-output, or --test-output-dir

Configuration

Project-wide defaults can be configured in Acton.toml:

[wrappers.tolk]
output-dir = "wrappers"
generate-test = true
test-output-dir = "tests"

[wrappers.typescript]
output-dir = "wrappers-ts"

CLI flags override config values for the current invocation.

Exit Status

  • 0: Wrapper generation completed successfully.
  • 1: The contract could not be found or compiled, ABI data was missing, the TypeScript generator could not run, or an output file could not be written.

Examples

  1. Generate the default Tolk wrapper:

    acton wrapper Counter
  2. Generate a wrapper and stub test:

    acton wrapper Counter --test
  3. Generate a TypeScript wrapper:

    acton wrapper Counter --ts
  4. Generate into custom locations:

    acton wrapper Counter --output-dir tests/generated
    acton wrapper Counter --test --test-output-dir tests/generated
    acton wrapper Counter --ts --output-dir wrappers-ts
  5. Generate a frontend-oriented TypeScript wrapper layout:

    acton wrapper Counter --ts --output-dir app/src/wrappers-ts

See Also

Last updated on

On this page