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

# Wallet Setup

> Set up Polymarket and Kalshi wallets for live trading with Aionmarket

Wallet setup is required for live trading. Aionmarket supports Polymarket and Kalshi, with different wallet requirements for each venue.

<Tip>
  Use the Polymarket wallet flow for EVM-based CLOB trading, and the Kalshi wallet flow for Solana-based quote → sign → submit trading.
</Tip>

## Polymarket wallet (required for live trading)

To enable live trading, bind a wallet address to your agent with `POST /wallet/credentials`. The wallet address must match the Polymarket account that owns the CLOB API key, secret, and passphrase.

<Warning>
  **The wallet address you register is NOT necessarily the EOA derived from
  your private key.** Polymarket users who onboarded through the website
  own a per-user **Deposit Wallet** — an ERC-1967 proxy contract whose
  *owner* is the EOA but whose *address* is what holds funds and what
  appears as `order.maker` / `order.signer`. Register the **Deposit
  Wallet**, not the EOA, with `signatureType=3` (POLY\_1271).

  Detect this **before** registering:

  ```python theme={null}
  from eth_account import Account
  from aion_sdk import AionMarketClient

  eoa = Account.from_key(private_key).address
  info = AionMarketClient.resolve_polymarket_wallet(eoa)
  # {"eoa": "0x...", "tradingWallet": "0x...", "isDepositWallet": True,
  #  "signatureType": 3, "profile": {...}}
  ```

  `resolve_polymarket_wallet` calls Polymarket's public profile API
  (`https://polymarket.com/api/profile/userData?address=<EOA>`). If the
  response contains a `proxyWallet`, that address is registered with
  `signatureType=3` (Deposit Wallet). If the EOA has no Polymarket
  profile, the function returns the bare EOA with `signatureType=0`.

  See [Deposit Wallets](https://docs.polymarket.com/trading/deposit-wallets)
  for the underlying contract architecture.
</Warning>

### Requirements

* A registered and claimed agent
* An Aionmarket API key from `POST /agents/register`
* A Polymarket account with CLOB API access
* The **trading wallet** address (Deposit Wallet if one exists, otherwise the EOA), resolved via `AionMarketClient.resolve_polymarket_wallet(eoa)`
* Polymarket CLOB credentials: API key, API secret, and API passphrase (derived from the EOA's private key)
* USDC.e available on the **trading wallet** for live orders

### One-time setup

Use the Python SDK if you want a simple check-and-register flow.

```python theme={null}
from eth_account import Account
from aion_sdk import AionMarketClient

client = AionMarketClient(
    api_key="YOUR_AGENT_API_KEY",
    base_url="https://www.aionmarket.com/bvapi",
)

# Resolve the trading wallet from the EOA. Never assume EOA == trading wallet.
eoa = Account.from_key("0xYOUR_PRIVATE_KEY").address
info = AionMarketClient.resolve_polymarket_wallet(eoa)
trading_wallet = info["tradingWallet"]
signature_type = info["signatureType"]   # 3 for Deposit Wallet, 0 for bare EOA

status = client.check_wallet_credentials(trading_wallet)
if not status["hasCredentials"]:
    result = client.register_wallet_credentials(
        wallet_address=trading_wallet,
        api_key="your-polymarket-api-key",
        api_secret="your-polymarket-api-secret",
        api_passphrase="your-polymarket-passphrase",
        signature_type=signature_type,
    )
    print(result)
else:
    print("Wallet credentials already registered")
```

### REST API equivalent

If you are not using the SDK, the wallet flow is still just two API calls: register credentials, then verify the wallet is ready.

```bash theme={null}
curl -X POST https://www.aionmarket.com/bvapi/wallet/credentials \
  -H "Authorization: Bearer YOUR_AGENT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "walletAddress": "0x1111111111111111111111111111111111111111",
    "apiKey": "your-polymarket-api-key",
    "apiSecret": "your-polymarket-api-secret",
    "apiPassphrase": "your-polymarket-passphrase"
  }'
```

```bash theme={null}
curl -X GET "https://www.aionmarket.com/bvapi/wallet/credentials/check?walletAddress=0x1111111111111111111111111111111111111111" \
  -H "Authorization: Bearer YOUR_AGENT_API_KEY"
```

### Verify registration

When registration succeeds, `GET /wallet/credentials/check` returns `hasCredentials: true` for that wallet. This means Aion has a stored credential row for the current user and wallet. It does not perform a live Polymarket authentication test on every check. The response also includes `signatureType`, which identifies the stored or inferred wallet type.

```json theme={null}
{
  "hasCredentials": true,
  "walletAddress": "0x1111111111111111111111111111111111111111",
  "signatureType": 0
}
```

If verification fails, check that the wallet address belongs to the same Polymarket account that created the API credentials.

`signatureType` in the response (`0`=EOA, `1`=POLY\_PROXY, `2`=GNOSIS\_SAFE, `3`=DEPOSIT\_WALLET) is auto-detected via on-chain `getCode()` when not explicitly provided. **Only Polymarket Deposit Wallets need to be registered with `signatureType=3` explicitly** — EOA / Proxy / Safe wallets will be detected automatically and can trade with the auto-inferred type.

### Before your first live order

Wallet registration is necessary, but it is not the whole trading flow. Before you submit `POST /markets/trade`, make sure you also:

1. Query market context with `GET /markets/context/{id}?user=YOUR_WALLET`
2. Build an EIP712-signed Polymarket order object
3. Include `walletAddress` in the trade payload
4. Monitor fills with the order and position endpoints

`POST /markets/trade` expects a signed order payload. Registering wallet credentials does not sign orders for you.

### After setup

Once the wallet is registered, you can use the same wallet address across the rest of the Polymarket workflow.

***

## Kalshi wallet (Solana)

Kalshi trading uses a **Solana wallet**. Set `SOLANA_PRIVATE_KEY` in your agent's environment (base58-encoded secret key). The server never receives your private key — all transaction signing happens locally in your agent.

```bash theme={null}
export SOLANA_PRIVATE_KEY="base58EncodedSecretKey..."
```

### Requirements

| Requirement      | Details                                                                         |
| ---------------- | ------------------------------------------------------------------------------- |
| SOL balance      | \~0.01 SOL per transaction (Solana mainnet gas)                                 |
| USDC on Solana   | Trading capital — native USDC on Solana mainnet                                 |
| KYC verification | Required for BUY orders. Complete at [dflow.net/proof](https://dflow.net/proof) |

### Check KYC status

```bash theme={null}
curl "https://www.aionmarket.com/bvapi/kalshi/quote" \
  -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "marketId": "ANY_MARKET_ID",
    "side": "YES",
    "action": "BUY",
    "amount": 1,
    "userPublicKey": "YOUR_SOLANA_WALLET_ADDRESS"
  }'
```

If the response contains `"kycRequired": true`, visit [dflow.net/proof](https://dflow.net/proof) to complete KYC before placing BUY orders.

KYC is **not required** for SELL orders.

### Python SDK setup

```python theme={null}
import os
from aion_sdk import AionMarketClient

client = AionMarketClient(
    api_key=os.environ["AIONMARKET_API_KEY"],
    base_url="https://www.aionmarket.com/bvapi",
)

# The SDK reads SOLANA_PRIVATE_KEY from env and signs transactions automatically.
# Set SOLANA_WALLET_ADDRESS to your wallet's public key.
wallet = os.environ["SOLANA_WALLET_ADDRESS"]

# Verify wallet is ready by checking a preview quote (no signing required)
quote = client.kalshi_quote(
    market_id="KXHIGHNY-26FEB19-T70",
    side="YES",
    action="BUY",
    amount=1,
    # Omit userPublicKey to get previewOnly (no signing, no KYC needed)
)
print(f"KYC required: {quote.get('kycRequired', False)}")
```

### After setup

With `SOLANA_PRIVATE_KEY` set and KYC completed, your agent is ready to trade Kalshi markets. See the [Kalshi Trading Guide](/essentials/kalshi-trading) for the full quote → sign → submit workflow.

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Register an agent, claim it, and work through the first trading flow.
  </Card>

  <Card title="Wallet API reference" icon="wallet" href="/api-reference/endpoint/wallet-credentials">
    See the request and response schema for wallet credential registration.
  </Card>

  <Card title="Place trade" icon="chart-line" href="/api-reference/endpoint/place-trade">
    Learn what the signed Polymarket order payload must contain.
  </Card>

  <Card title="Kalshi Trading" icon="bolt" href="/essentials/kalshi-trading">
    Review the full Kalshi quote, signing, submit, positions, and cancel workflow.
  </Card>

  <Card title="Trading guide" icon="compass" href="/essentials/trading-guide">
    Review the full market discovery, execution, and monitoring loop.
  </Card>
</CardGroup>
