|
| 1 | +--- |
| 2 | +sidebar_position: 4 |
| 3 | +title: Chain Command Runner (chaincmd/runner) |
| 4 | +slug: /packages/chaincmdrunner |
| 5 | +--- |
| 6 | + |
| 7 | +# Chain Command Runner (chaincmd/runner) |
| 8 | + |
| 9 | +The `chaincmdrunner` package wraps chain binary commands into typed, higher-level operations (accounts, genesis setup, tx queries, node control). |
| 10 | + |
| 11 | +For full API details, see the |
| 12 | +[`chaincmdrunner` Go package documentation](https://pkg.go.dev/github.com/ignite/cli/v29/ignite/pkg/chaincmd/runner). |
| 13 | + |
| 14 | +## When to use |
| 15 | + |
| 16 | +- Execute chain lifecycle commands without manually assembling CLI arguments. |
| 17 | +- Manage accounts and genesis setup from automation/test flows. |
| 18 | +- Query transaction events using typed selectors instead of raw command output parsing. |
| 19 | + |
| 20 | +## Key APIs |
| 21 | + |
| 22 | +- `New(ctx context.Context, chainCmd chaincmd.ChainCmd, options ...Option) (Runner, error)` |
| 23 | +- `(Runner) Init(ctx context.Context, moniker string, args ...string) error` |
| 24 | +- `(Runner) Start(ctx context.Context, args ...string) error` |
| 25 | +- `(Runner) AddAccount(ctx context.Context, name, mnemonic, coinType, accountNumber, addressIndex string) (Account, error)` |
| 26 | +- `(Runner) AddGenesisAccount(ctx context.Context, address, coins string) error` |
| 27 | +- `(Runner) QueryTxByEvents(ctx context.Context, selectors ...EventSelector) ([]Event, error)` |
| 28 | +- `(Runner) WaitTx(ctx context.Context, txHash string, retryDelay time.Duration, maxRetry int) error` |
| 29 | + |
| 30 | +## Common Tasks |
| 31 | + |
| 32 | +- Build a `Runner` from a configured `chaincmd.ChainCmd` and then call `Init`/`Start` for local node workflows. |
| 33 | +- Use `AddAccount`, `ListAccounts`, and `ShowAccount` to manage keyring state in scripted flows. |
| 34 | +- Query and filter tx events with `NewEventSelector` plus `QueryTxByEvents`. |
| 35 | + |
| 36 | +## Basic import |
| 37 | + |
| 38 | +```go |
| 39 | +import chaincmdrunner "github.com/ignite/cli/v29/ignite/pkg/chaincmd/runner" |
| 40 | +``` |
0 commit comments