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

# Request Ownership Challenge

> POST /v1/wallets/challenge — Get a one-time message to sign with a wallet, to prove you control it

> [!NOTE]
>
> **Endpoint:** `POST https://api.rebelfi.io/v1/wallets/challenge`

Request a one-time challenge for a wallet address. Sign the returned `message` with the wallet, then send the
`challengeId` and the signature to [Register Wallet](https://docs.rebelfi.io/docs/api-reference/wallets/register.md) (as `proof`) or
[Verify Wallet](https://docs.rebelfi.io/docs/api-reference/wallets/verify.md). A wallet proven this way is `CONTROLLED`: its balance is booked to your
organization, and it can Supply, Unwind and Transfer Out.

A challenge is bound to your organization, the chain and the address. It can be used once and expires after about ten
minutes (`expiresAt`).

### Request Body

| Field | Type | Required | Description |
| - | - | - | - |
| `walletAddress` | `string` | Yes | Wallet address on the blockchain |
| `blockchain` | `string` | Yes | Blockchain network: `solana`, `polygon`, `ethereum`, or `base` |

### Example Request

```bash cURL theme={null}
curl -X POST "https://api.rebelfi.io/v1/wallets/challenge" \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "So11...abc",
    "blockchain": "solana"
  }'
```

```typescript SDK theme={null}
const { challengeId, message, expiresAt } = await client.wallets.challenge({
  walletAddress: 'So11...abc',
  blockchain: 'solana'
});
```

### Example Response

```json theme={null}
{
  "challengeId": 917,
  "message": "Midas wallet ownership\nOrganization: 12\nChain: solana\nAddress: So11...abc\nNonce: 4f9c2a...\nExpires: 2024-01-15T10:40:00.000Z",
  "expiresAt": "2024-01-15T10:40:00.000Z"
}
```

### Response Fields

| Field | Type | Description |
| - | - | - |
| `challengeId` | `number` | Send it with the signature |
| `message` | `string` | The exact text to sign. Don't change or trim it |
| `expiresAt` | `string` | Sign and submit before this time (ISO 8601) |

### Signing the Message

Sign with the same key that controls the address, using the signer you already use for transactions.

> [tab] Solana
>
> An ed25519 signature over the UTF-8 bytes of `message`, base58-encoded. Wallet adapters expose this as
> `signMessage`.
>
> ```typescript theme={null}
> import nacl from 'tweetnacl';
> import bs58 from 'bs58';
>
> const bytes = new TextEncoder().encode(message);
> const signature = bs58.encode(nacl.sign.detached(bytes, keypair.secretKey));
> // Wallet adapter: bs58.encode(await wallet.signMessage(bytes))
> ```

> [tab] EVM
>
> A `personal_sign` signature of `message` (EIP-191), as 0x hex. Smart contract wallets are verified on-chain with
> ERC-1271 (`isValidSignature`), so a Safe or other contract account works if it can sign messages.
>
> ```typescript theme={null}
> // ethers v6
> const signature = await signer.signMessage(message);
>
> // viem
> const signature = await walletClient.signMessage({ account, message });
> ```

> [!NOTE]
>
> A wallet that can't sign messages (for example a Solana multisig or a program-derived address) can't use this flow.
> Contact support to verify it another way.

### Errors

| Code | HTTP | Description |
| - | - | - |
| `VALIDATION_FAILED` | 400 | Missing field, or an address that isn't valid for the chain |
| `FORBIDDEN` | 403 | Admin API keys are read-only; use a key scoped to a wallet profile |


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