> ## Documentation Index
> Fetch the complete documentation index at: https://trust-link-tsn.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cranker SDK — Submit authorized TSN work

> Use the Cranker SDK's on-chain helpers to initialize operator state, register a Cranker, fund its vault, and manage protocol setup.

`@trustlink/tsn-cranker-sdk` provides operator-side setup helpers and the `tsn-cranker` CLI. A Cranker submits only the authorized transaction; it does not decide route policy or create payment authorization.

## Public setup helpers

The CLI delegates to these exported functions from `@trustlink/tsn-sdk/blockchain/solana-tsn`:

| Function                            | Purpose                                          | Return                                    |
| ----------------------------------- | ------------------------------------------------ | ----------------------------------------- |
| `tsnInitializeMotherEscrowOnChain`  | Initialize Mother escrow state.                  | Source-defined transaction/result object. |
| `tsnMigrateMotherEscrowOnChain`     | Migrate an invalid or old Mother layout.         | Source-defined transaction/result object. |
| `tsnRegisterCrankerOnChain`         | Register the operator as a Cranker.              | Source-defined transaction/result object. |
| `tsnSetCrankerFundingPolicyOnChain` | Set whether external Cranker funding is allowed. | Source-defined transaction/result object. |
| `tsnInitializeCrankerVaultOnChain`  | Initialize a token vault for a Cranker.          | Source-defined transaction/result object. |
| `tsnFundCrankerOnChain`             | Fund a Cranker's token vault.                    | Source-defined transaction/result object. |
| `tsnWithdrawCrankerFundsOnChain`    | Withdraw Cranker vault funds.                    | Source-defined transaction/result object. |

TODO: confirm each helper's generated return type from `blockchain/solana-tsn.ts` before documenting field-level response entries.

## Direct TypeScript use

```ts theme={null}
import { tsnRegisterCrankerOnChain } from "@trustlink/tsn-sdk/blockchain/solana-tsn";

const result = await tsnRegisterCrankerOnChain({
  operator,
  rpcUrl: process.env.TSN_RPC_GATEWAY_URL,
  secretKey: process.env.SOLANA_ESCROW_AUTHORITY_SECRET_KEY,
});
console.log(result);
```

The command requires a local Solana keypair and uses `TSN_RPC_GATEWAY_URL` when configured by `resolveSolanaRpcUrl`.

Source: [`cli.ts:1-188`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-cranker-sdk/src/cli.ts#L1-L188), [`index.ts`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-cranker-sdk/src/index.ts), [`solana-tsn.ts`](https://github.com/Trustlink-Labs/TSN-Protocol/blob/main/tsn-protocol/sdks/tsn-sdk/src/blockchain/solana-tsn.ts)
