> ## 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.

# addEcdsaKey

> Add a secp256k1 (ECDSA) key 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. The configured
owner signs the change, and the new role gets the next free role id.

Only the public key is used; it is SEC1-compressed and lowercased. An
uncompressed key must lie on secp256k1. Pass the public key of the signer an
account will be configured with as `{ type: 'ecdsa', account }`: a compressed
key from another curve cannot be told apart, and would install a role no one
can sign for. An EVM address is refused, never read as a key.

The example assumes an authenticated `sdk`, an existing passkey-root
`account` with authority-management permission, its saved `swig` address,
a viem `recoverySigner` and its matching secp256k1 `recoveryPublicKey`, and
a viem WebAuthn `newPasskey`. Authority changes are intrinsically sponsored;
integrator sponsorship must be enabled. Do not add a `sponsored` flag.

## Import

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

## Usage

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

// The passkey-root account enrolls a recovery key that can only manage authorities.
const enroll = {
  destination: {
    chain: solanaDevnet,
    authority: addEcdsaKey(recoveryPublicKey, { permission: 'manageAuthority' }),
  },
}
const signed = await account.signTransaction(await account.prepareTransaction(enroll))
await account.waitForExecution(await account.submitTransaction(signed))
const { status } = await account.getAuthorityStatus(enroll) // 'applied'

// Later, the recovery signer adds a new passkey; its key never leaves the signer.
const recovery = await sdk.createAccount({
  solana: {
    owner: {
      type: 'ecdsa',
      account: recoverySigner,
    },
    swig,
  },
})
await recovery.prepareTransaction({
  destination: {
    chain: solanaDevnet,
    authority: addPasskey(newPasskey, { permission: 'all' }),
  },
})
```

## Parameters

<ParamField path="key" type="`0x${string}` | {}" required>
  The key to add: a viem local account, or its secp256k1 public key
  as 33-byte compressed, 65-byte uncompressed or 64-byte x‖y hex.
</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

* [removeEcdsaKey](/wallets/custom-signer/sdk-reference/solana/remove-ecdsa-key)


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