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

# addPasskey

> Add a passkey to a managed Solana account's Swig.

Builds the `authority` of a `{ destination: { chain, authority } }`
transaction, which then runs through `prepareTransaction`,
`signTransaction` and `submitTransaction` like any other.

Only the passkey's public key is used; it is SEC1-compressed and
lowercased. The configured owner signs the change, and the new role gets
the next free role id.

## Import

```ts theme={null}
import { addPasskey } from '@rhinestone/sdk/solana'
```

## Usage

```ts theme={null}
import { addPasskey, removePasskey, solanaDevnet } from '@rhinestone/sdk/solana'

// Add a passkey that can spend but not manage authorities.
const added = await account.prepareTransaction({
  destination: {
    chain: solanaDevnet,
    authority: addPasskey(newPasskey, { permission: 'allButManageAuthority' }),
  },
})
const signed = await account.signTransaction(added)
await account.waitForExecution(await account.submitTransaction(signed))

// An account configured with the new passkey as owner spends from the same wallet.
const same = await sdk.createAccount({
  solana: { owner: { type: 'passkey', account: newPasskey }, swig },
})

// Remove it again.
await account.prepareTransaction({
  destination: {
    chain: solanaDevnet,
    authority: removePasskey(newPasskey),
  },
})
```

## Parameters

<ParamField path="passkey" type="`0x${string}` | WebAuthnAccount" required>
  The passkey to add: a viem WebAuthn account, or its P-256
  public key in 64-byte x‖y, 65-byte uncompressed or 33-byte compressed form.
</ParamField>

<ParamField path="options" type="{ permission: SolanaAuthorityPermission }" required>
  `permission`, what the new role may do (required, no default):
  `allButManageAuthority` spends and runs instructions; `manageAuthority` adds
  and removes non-root authorities but never spends; `all` does both. Either
  permission that manages authorities can grant `all`, so it controls the wallet.
</ParamField>

## Returns

A frozen `SolanaAuthorityChange` for `prepareTransaction`

<ResponseField name="action" type="'add'" required />

<ResponseField name="key" type="SolanaAuthorityKey" required />

<ResponseField name="permission" type="SolanaAuthorityPermission" required />

## See also

* [removePasskey](/wallets/custom-signer/sdk-reference/solana/remove-passkey)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.