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

# Wallet Operations

> Create wallets and sign transactions using Express API endpoints for wallet management and signing operations.

## Wallet Management

### Get or Create Wallet

Get or create a wallet for the given chain and return its public address. If a wallet doesn't exist for the user and chain combination, one will be created automatically.

```bash cURL icon="square-terminal" theme={null}
curl -X POST 'https://tee.express.magiclabs.com/v1/wallet' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'X-Magic-API-Key: YOUR_MAGIC_API_KEY' \
  -H 'X-OIDC-Provider-ID: YOUR_OIDC_PROVIDER_ID' \
  -H 'X-Magic-Chain: ETH' 
```

**Response:**

```json theme={null}
{
  "public_address": "0x1234567890abcdef1234567890abcdef12345678"
}
```

#### Request Parameters

<ParamField header="X-Magic-Chain" type="string" required post={["Header"]}>
  The blockchain to create the wallet for. Available values: `ETH`, `SOL`, `BTC`
</ParamField>

#### Response Fields

<ResponseField name="public_address" type="string">
  The wallet's public address on the specified blockchain.
</ResponseField>

<Info>
  Each user can have one wallet per blockchain. Calling this endpoint multiple times with the same user and chain will return the same wallet address.
</Info>

## Signing Operations

### Sign Data

Sign a hash of arbitrary data using the wallet's private key. This is useful for signing transaction data, typed data, or any structured information.

```bash cURL icon="square-terminal" theme={null}
curl -X POST 'https://tee.express.magiclabs.com/v1/wallet/sign/data' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'X-Magic-API-Key: YOUR_MAGIC_API_KEY' \
  -H 'X-OIDC-Provider-ID: YOUR_OIDC_PROVIDER_ID' \
  -H 'X-Magic-Chain: ETH' \
  -d '{
    "raw_data_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
  }'
```

**Response:**

```json theme={null}
{
  "message_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "signature": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
  "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef12345678",
  "v": "27"
}
```

#### Request Parameters

<ParamField header="X-Magic-Chain" type="string" required post={["Header"]}>
  The blockchain to sign for. Available values: `ETH`, `SOL`, `BTC`
</ParamField>

<ParamField body="raw_data_hash" type="string" required post={["Body"]}>
  The keccak256 hash of the data to sign (hex string with 0x postfix).
</ParamField>

#### Response Fields

<ResponseField name="message_hash" type="string">
  The hash that was signed.
</ResponseField>

<ResponseField name="signature" type="string">
  The complete signature in hex format.
</ResponseField>

<ResponseField name="r" type="string">
  The r component of the ECDSA signature.
</ResponseField>

<ResponseField name="s" type="string">
  The s component of the ECDSA signature.
</ResponseField>

<ResponseField name="v" type="string">
  The recovery parameter of the ECDSA signature.
</ResponseField>

### Sign EIP-7702 Authorization

Sign an [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) authorization that delegates an EOA to a smart contract implementation. This is used to temporarily upgrade an EOA into a smart wallet for a transaction bundle, enabling features like batched calls and gas sponsorship.

```bash cURL icon="square-terminal" theme={null}
curl -X POST 'https://tee.express.magiclabs.com/v1/wallet/sign/eip7702' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'X-Magic-API-Key: YOUR_MAGIC_API_KEY' \
  -H 'X-OIDC-Provider-ID: YOUR_OIDC_PROVIDER_ID' \
  -H 'X-Magic-Chain: ETH' \
  -d '{
    "chain_id": 84532,
    "address": "0x1234567890abcdef1234567890abcdef12345678",
    "nonce": 0
  }'
```

**Response:**

```json theme={null}
{
  "r": "12345678901234567890123456789012345678901234567890123456789012345678",
  "s": "98765432109876543210987654321098765432109876543210987654321098765432",
  "y_parity": 0
}
```

#### Request Parameters

<ParamField header="X-Magic-Chain" type="string" required post={["Header"]}>
  The blockchain to sign for. Available values: `ETH`
</ParamField>

<ParamField body="chain_id" type="number" required post={["Body"]}>
  The chain ID for the authorization (e.g., `84532` for Base Sepolia).
</ParamField>

<ParamField body="address" type="string" required post={["Body"]}>
  The smart contract address to delegate to (20-byte hex string).
</ParamField>

<ParamField body="nonce" type="number" required post={["Body"]}>
  The authorization nonce.
</ParamField>

#### Response Fields

<ResponseField name="r" type="string">
  The r component of the ECDSA signature (decimal string).
</ResponseField>

<ResponseField name="s" type="string">
  The s component of the ECDSA signature (decimal string).
</ResponseField>

<ResponseField name="y_parity" type="number">
  The y-parity bit (`0` or `1`) used for EIP-7702 signature recovery.
</ResponseField>

### Sign Message

Sign an arbitrary message using the wallet's private key. Useful for authentication, off-chain verification, and personal signatures.

```bash cURL icon="square-terminal" theme={null}
curl -X POST 'https://tee.express.magiclabs.com/v1/wallet/sign/message' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_JWT_TOKEN' \
  -H 'X-Magic-API-Key: YOUR_MAGIC_API_KEY' \
  -H 'X-OIDC-Provider-ID: YOUR_OIDC_PROVIDER_ID' \
  -H 'X-Magic-Chain: ETH' \
  -d '{
    "message_base64": "SGVsbG8gV29ybGQ="
  }'
```

**Response:**

```json theme={null}
{
  "signature": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12",
  "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
  "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef12345678",
  "v": "27"
}
```

#### Request Parameters

<ParamField header="X-Magic-Chain" type="string" required post={["Header"]}>
  The blockchain to sign for. Available values: `ETH`, `SOL`, `BTC`
</ParamField>

<ParamField body="message_base64" type="string" required post={["Body"]}>
  The message to sign, encoded as base64.
</ParamField>

#### Response Fields

<ResponseField name="signature" type="string">
  The complete signature in hex format.
</ResponseField>

<ResponseField name="r" type="string">
  The r component of the ECDSA signature.
</ResponseField>

<ResponseField name="s" type="string">
  The s component of the ECDSA signature.
</ResponseField>

<ResponseField name="v" type="string">
  The recovery parameter of the ECDSA signature.
</ResponseField>
