# Create an Account

## Overview

Tempo provides Viem-compatible [Local Accounts](/docs/accounts/local) that support multiple
signature schemes: secp256k1 (standard Ethereum keys), P256, WebAuthn (passkeys), and WebCrypto
(device-bound keys). Each is created from the [`Account`](/tempo/accounts) namespace and works
with any Viem Action that accepts an `account`.

## Recipes

These recipes assume you have [set up a Tempo client](/tempo).

### Create from a Private Key

Use [`Account.fromSecp256k1`](/tempo/accounts/account.fromSecp256k1) to create a standard
Ethereum account from a secp256k1 private key.

```ts twoslash
import { Account } from 'viem/tempo'

const account = Account.fromSecp256k1(
  '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
)
```

### Create from a P256 Private Key

Use [`Account.fromP256`](/tempo/accounts/account.fromP256) to create an account from a P256
private key.

```ts twoslash
import { Account, P256 } from 'viem/tempo'

const account = Account.fromP256(P256.randomPrivateKey())
```

### Create from a Passkey

Use [`Account.fromWebAuthnP256`](/tempo/accounts/account.fromWebAuthnP256) to create an account
backed by a WebAuthn credential (passkey). See [Sign In with a Passkey](/tempo/guides/accounts/passkeys)
for the full create and restore flow.

```ts twoslash
// @noErrors
import { Account, WebAuthnP256 } from 'viem/tempo'

const credential = await WebAuthnP256.createCredential({ name: 'Example' })

const account = Account.fromWebAuthnP256(credential)
```

### Create from a Device-Bound Key

Use [`Account.fromWebCryptoP256`](/tempo/accounts/account.fromWebCryptoP256) with a
non-extractable [WebCrypto key pair](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKeyPair).
The private key never leaves the device, which makes it a good fit for [Access Keys](/tempo/guides/access-keys).

```ts twoslash
import { Account, WebCryptoP256 } from 'viem/tempo'

const keyPair = await WebCryptoP256.createKeyPair()

const account = Account.fromWebCryptoP256(keyPair)
```

### Use an Account with Actions

Set an account as the client default, or pass it per call to any Action that accepts an
`account`.

:::code-group
```ts twoslash [example.ts]
import { Account } from 'viem/tempo'
import { client } from './viem.config'

const account = Account.fromSecp256k1(
  '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
)

const receipt = await client.sendTransactionSync({
  account, // [!code focus]
  data: '0xdeadbeef',
  to: '0xcafebabecafebabecafebabecafebabecafebabe',
})
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
// [!include ~/snippets/tempo/viem.config.ts:setup]
```
:::

## Best Practices

### Choose the Right Signing Scheme

Use secp256k1 for standard backend or scripting keys, P256 for systems that require it,
passkeys (WebAuthn) for user-facing browser sign-in, and WebCrypto for non-extractable
device-bound keys. Passkeys and WebCrypto keys pair well with [Access Keys](/tempo/guides/access-keys)
since they cannot be exported.

### Persist Passkey Public Keys

A WebAuthn account's address is derived from its public key, so store the credential's public
key in an external store when you create it. You will need it to restore the account later. See
[Sign In with a Passkey](/tempo/guides/accounts/passkeys).

## See More

<Cards>
  <Card icon="lucide:fingerprint" title="Sign In with a Passkey" description="Create and restore WebAuthn passkey accounts for browser sign-in." to="/tempo/guides/accounts/passkeys" />

  <Card icon="lucide:key-round" title="Access Keys" description="Delegate signing to a secondary key without exposing the primary key." to="/tempo/guides/access-keys" />

  <Card icon="lucide:square-function" title="Accounts Reference" description="The full API reference for every Tempo account type." to="/tempo/accounts" />
</Cards>
