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

# Create Crypto Wallets

> Generate blockchain wallets with deterministic keys in Phala Cloud

Create blockchain wallets using deterministic keys derived from your application's root key. Each wallet address is unique to your application and consistently reproducible.

## Prerequisites

Your application must be running in the Phala Cloud TEE environment with access to the dstack socket. In your `docker-compose.yml`:

```yaml theme={"system"}
services:
  app:
    # your app configuration
    volumes:
      - /var/run/dstack.sock:/var/run/dstack.sock
```

## Ethereum Wallet

<CodeGroup dropdown>
  ```javascript ethereum.js theme={"system"}
  import { DstackClient } from '@phala/dstack-sdk';
  import { toViemAccountSecure } from '@phala/dstack-sdk/viem';

  const client = new DstackClient();
  const keyResult = await client.getKey('wallet/ethereum/mainnet');
  const account = toViemAccountSecure(keyResult);

  console.log('Address:', account.address);
  ```

  ```python ethereum.py theme={"system"}
  from dstack_sdk import DstackClient
  from eth_account import Account

  client = DstackClient()
  result = client.get_key('wallet/ethereum/mainnet')
  account = Account.from_key(result.decode_key())

  print(f'Address: {account.address}')
  ```
</CodeGroup>

## Solana Wallet

<CodeGroup dropdown>
  ```javascript solana.js theme={"system"}
  import { DstackClient } from '@phala/dstack-sdk';
  import { toKeypairSecure } from '@phala/dstack-sdk/solana';

  const client = new DstackClient();
  const keyResult = await client.getKey('wallet/solana/mainnet');
  const keypair = toKeypairSecure(keyResult);

  console.log('Address:', keypair.publicKey.toBase58());
  ```

  ```python solana.py theme={"system"}
  from dstack_sdk import DstackClient
  from solders.keypair import Keypair

  client = DstackClient()
  result = client.get_key('wallet/solana/mainnet')
  keypair = Keypair.from_bytes(result.decode_key())

  print(f'Address: {keypair.pubkey()}')
  ```
</CodeGroup>

## Important Security Notes

* **Use secure functions**: Always use `toViemAccountSecure()` and `toKeypairSecure()` (not the legacy versions)
* **Application-specific**: Wallet addresses are unique to your application ID
* **Deterministic**: Same path always generates the same wallet
* **Keep keys in TEE**: Never expose private keys outside the secure environment

## Multi-Wallet Support

Generate multiple wallets by using different paths:

<CodeGroup dropdown>
  ```javascript multiWallet.js theme={"system"}
  // User wallets
  const userWallet = await client.getKey('wallet/user/123/v1');

  // Treasury wallet
  const treasury = await client.getKey('wallet/treasury/v1');

  // Hot wallet for operations
  const hotWallet = await client.getKey('wallet/hot/v1');
  ```

  ```python multi_wallet.py theme={"system"}
  # User wallets
  user_wallet = client.get_key('wallet/user/123/v1')

  # Treasury wallet
  treasury = client.get_key('wallet/treasury/v1')

  # Hot wallet for operations
  hot_wallet = client.get_key('wallet/hot/v1')
  ```
</CodeGroup>

## Migration from v0.3.x

If you're upgrading from dstack v0.3.x, **wallet addresses will change** when using secure functions. See the [Migration from dstack v0.3](/phala-cloud/references/migration-from-dstack-v03) guide for detailed upgrade instructions and wallet migration strategies.
