> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

# Registering Plugins

> Extend the Wallet SDK with custom methods using the plugin system.

The Wallet SDK supports extending its functionality through a plugin system. Plugins allow you to add custom methods and functionality to the SDK instance while maintaining access to the SDK context and logger.

### Creating and Registering a Plugin

To create a plugin, extend the `SDKPlugin` class and implement your custom functionality. Plugins are registered using the `registerPlugins` method, which accepts a record of plugin constructors keyed by their desired property names.

```typescript theme={"theme":{"light":"github-light","dark":"github-dark"}}
import { SDK, SDKContext, SDKPlugin } from '@canton-network/wallet-sdk'

export default async function () {
    const sdk = (
        await SDK.create({
            auth: {
                method: 'self_signed',
                issuer: 'unsafe-auth',
                credentials: {
                    clientId: 'ledger-api-user',
                    clientSecret: 'unsafe',
                    audience: 'https://canton.network.global',
                    scope: '',
                },
            },
            ledgerClientUrl: 'http://localhost:2975',
        })
    ).registerPlugins({
        myPlugin: class extends SDKPlugin {
            // wallet-sdk plugin should always accept SDKContext
            constructor(protected readonly ctx: SDKContext) {
                super('myPlugin', ctx)
            }

            myMethod() {
                // do some logic
                return
            }
        },
    })

    sdk.myPlugin.myMethod()
}
```

### Key Points

* **Plugin Constructor**: Plugin classes must accept `SDKContext` as a constructor parameter and pass it to the `super()` call along with the plugin name.
* **Type Safety**: The `registerPlugins` method provides full type safety, ensuring that registered plugins are accessible with proper autocompletion and type checking.
* **Access to SDK Context**: Plugins have access to the SDK's context, logger, and other internal utilities through the `ctx` property.
* **Multiple Plugins**: You can register multiple plugins at once by passing them in a single object to `registerPlugins`.
