> ## Documentation Index
> Fetch the complete documentation index at: https://base-a060aa97-fix-dead-service-links.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# getCryptoKeyAccount

> Retrieve the current crypto key account associated with the user's session

export const Button = ({children, disabled, variant = "primary", size = "medium", iconName, roundedFull = false, className = '', fullWidth = false, onClick = undefined}) => {
  const variantStyles = {
    primary: 'bg-blue text-black border border-blue hover:bg-blue-80 active:bg-[#06318E] dark:text-white',
    secondary: 'bg-white border border-white text-palette-foreground hover:bg-zinc-15 active:bg-zinc-30',
    outlined: 'bg-transparent text-white border border-white hover:bg-white hover:text-black active:bg-[#E3E7E9]'
  };
  const sizeStyles = {
    medium: 'text-md px-4 py-2 gap-3',
    large: 'text-lg px-6 py-4 gap-5'
  };
  const sizeIconRatio = {
    medium: '0.75rem',
    large: '1rem'
  };
  const classes = ['text-md px-4 py-2 whitespace-nowrap', 'flex items-center justify-center', 'disabled:opacity-40 disabled:pointer-events-none', 'transition-all', variantStyles[variant], sizeStyles[size], roundedFull ? 'rounded-full' : 'rounded-lg', fullWidth ? 'w-full' : 'w-auto', className];
  const buttonClasses = classes.filter(Boolean).join(' ');
  const iconSize = sizeIconRatio[size];
  return <button type="button" disabled={disabled} className={buttonClasses} onClick={onClick}>
      <span>{children}</span>
      {iconName && <Icon name={iconName} width={iconSize} height={iconSize} color="currentColor" />}
    </button>;
};

export const BaseBanner = ({content = null, id, dismissable = true}) => {
  const LOCAL_STORAGE_KEY_PREFIX = 'cb-docs-banner';
  const [isVisible, setIsVisible] = useState(false);
  const onDismiss = () => {
    localStorage.setItem(`${LOCAL_STORAGE_KEY_PREFIX}-${id}`, 'false');
    setIsVisible(false);
  };
  useEffect(() => {
    const storedValue = localStorage.getItem(`${LOCAL_STORAGE_KEY_PREFIX}-${id}`);
    setIsVisible(storedValue !== 'false');
  }, []);
  if (!isVisible) {
    return null;
  }
  return <div className="fixed bottom-0 left-0 right-0 bg-white py-8 px-4 lg:px-12 z-50 text-black dark:bg-black dark:text-white border-t dark:border-gray-95">
      <div className="flex items-center max-w-8xl mx-auto">
        {typeof content === 'function' ? content({
    onDismiss
  }) : content}
        {dismissable && <button onClick={onDismiss} className="flex-shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors" aria-label="Dismiss banner">
          ✕
        </button>}
      </div>
    </div>;
};

Defined in the [Base Account SDK](https://github.com/base/account-sdk)

## Parameters

This function takes no parameters.

## Returns

<ResponseField name="result" type="CryptoKeyAccountResult">
  An object containing the user's crypto key account information or null if none exists.

  <Expandable title="CryptoKeyAccountResult properties">
    <ResponseField name="account" type="WebAuthnAccount | LocalAccount | null">
      The user's crypto key account object, or null if none is available.

      <Expandable title="WebAuthnAccount properties">
        <ResponseField name="publicKey" type="string">
          Public key associated with the account.
        </ResponseField>

        <ResponseField name="type" type="string">
          Account type identifier. Value: "webauthn"
        </ResponseField>
      </Expandable>

      <Expandable title="LocalAccount properties">
        <ResponseField name="address" type="string">
          Ethereum address of the account (42-character hex string starting with 0x).
        </ResponseField>

        <ResponseField name="publicKey" type="string">
          Public key associated with the account.
        </ResponseField>

        <ResponseField name="type" type="string">
          Account type identifier. Value: "local"
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```typescript Basic Usage theme={null}
  import { getCryptoKeyAccount } from '@base-org/account';

  const cryptoAccount = await getCryptoKeyAccount();
  if (cryptoAccount?.account) {
    console.log('Account address:', cryptoAccount.account.address);
  }
  ```

  ```typescript Account Verification theme={null}
  const cryptoAccount = await getCryptoKeyAccount();

  if (!cryptoAccount?.account) {
    console.log('No account found - user needs to sign in');
    return null;
  }

  const { account } = cryptoAccount;
  console.log('Account type:', account.type);
  ```
</RequestExample>

<ResponseExample>
  ```typescript Success Response (WebAuthn Account) theme={null}
  {
    account: {
      address: "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
      publicKey: "0x04a1b2c3d4e5f6...",
      type: "webauthn"
    }
  }
  ```

  ```typescript Success Response (Local Account) theme={null}
  {
    account: {
      address: "0x742d35Cc4Bf53E0e6C42E5d9F0A8D2F6D8A8B7C9",
      publicKey: "0x04b2c3d4e5f6a7...",
      type: "local"
    }
  }
  ```

  ```typescript Success Response (No Account) theme={null}
  {
    account: null
  }
  ```
</ResponseExample>

## Error Handling

| Code | Message                    | Description                                     |
| ---- | -------------------------- | ----------------------------------------------- |
| 4001 | User denied account access | User rejected the account access request        |
| 4100 | SDK not initialized        | Base Account SDK not properly initialized       |
| 4200 | Session expired            | User session has expired, requires reconnection |
| 4300 | Account unavailable        | Account temporarily unavailable                 |

<Warning>
  Always check if the account exists before using it, as users may not be connected or may have disconnected.
</Warning>

## Account State Management

```typescript theme={null}
import { getCryptoKeyAccount } from '@base-org/account';

class AccountManager {
  private currentAccount: WebAuthnAccount | LocalAccount | null = null;
  
  async initialize() {
    const cryptoAccount = await getCryptoKeyAccount();
    this.currentAccount = cryptoAccount?.account || null;
    
    return this.isConnected();
  }
  
  isConnected(): boolean {
    return !!this.currentAccount;
  }
  
  getAddress(): string | null {
    return this.currentAccount?.address || null;
  }
  
  getAccountType(): 'webauthn' | 'local' | null {
    return this.currentAccount?.type || null;
  }
  
  async refresh() {
    const cryptoAccount = await getCryptoKeyAccount();
    const newAccount = cryptoAccount?.account;
    
    // Check if account changed
    if (newAccount?.address !== this.currentAccount?.address) {
      console.log('Account changed:', newAccount?.address);
      this.currentAccount = newAccount;
      return true;
    }
    
    return false;
  }
}
```

## Integration with Provider

```typescript theme={null}
import { getCryptoKeyAccount, createBaseAccountSDK } from '@base-org/account';

async function initializeApp() {
  const sdk = createBaseAccountSDK({
    appName: 'My App',
    appLogoUrl: 'https://example.com/logo.png',
    appChainIds: [8453], // Base mainnet
  });
  
  // Check current account status
  const cryptoAccount = await getCryptoKeyAccount();
  
  if (cryptoAccount?.account) {
    console.log('User is already connected:', cryptoAccount.account.address);
    
    // Get provider for transactions
    const provider = sdk.getProvider();
    
    return {
      sdk,
      provider,
      account: cryptoAccount.account,
      isConnected: true
    };
  } else {
    console.log('User needs to connect');
    
    return {
      sdk,
      provider: null,
      account: null,
      isConnected: false
    };
  }
}
```

## Account Verification

```typescript theme={null}
async function verifyAccountAccess() {
  const cryptoAccount = await getCryptoKeyAccount();
  
  if (!cryptoAccount?.account) {
    throw new Error('No account available');
  }
  
  const { account } = cryptoAccount;
  
  // Verify account has required properties
  if (!account.address || !account.publicKey) {
    throw new Error('Invalid account data');
  }
  
  // Verify address format
  if (!/^0x[a-fA-F0-9]{40}$/.test(account.address)) {
    throw new Error('Invalid address format');
  }
  
  return account;
}
```

<BaseBanner
  id="privacy-policy"
  dismissable={false}
  content={({ onDismiss }) => (
<div className="flex items-center">
  <div className="mr-2">
    We're updating the Base Privacy Policy, effective July 25, 2025, to reflect an expansion of Base services. Please review the updated policy here:{" "}
    <a
      href="https://docs.base.org/privacy-policy-2025"
      target="_blank"
      className="whitespace-nowrap"
    >
      Base Privacy Policy
    </a>. By continuing to use Base services, you confirm that you have read and understand the updated policy.
  </div>
  <Button onClick={onDismiss}>I Acknowledge</Button>
</div>
)}
/>
