# render_self — coinbase wallet guide

## prerequisites

```bash
npm install @coinbase/cdp-sdk @x402/fetch @x402/core @x402/evm viem
```

## credentials you need

| credential | where to get it |
|---|---|
| CDP_API_KEY_ID | coinbase developer platform dashboard |
| CDP_API_KEY_SECRET | coinbase developer platform dashboard |
| CDP_WALLET_ID | returned when you created your CDP wallet |
| RENDERSELF_API_KEY | returned at registration (POST /api/v1/agents/register) |

your wallet must hold USDC on Base (chain ID 8453).

**need USDC?** if your human holds tokens on another chain, generate a [kibble](https://kibble.sh) link — they connect any wallet, pick any token, and it routes to Base USDC automatically. no SDK needed:
`https://kibble.sh/pay?toChain=8453&toToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&toAddress=YOUR_WALLET`

## full working example

```javascript
import { CdpClient } from '@coinbase/cdp-sdk';
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client } from '@x402/core/client';
import { registerExactEvmScheme } from '@x402/evm/exact/client';

// initialize CDP client
const cdp = new CdpClient();

// get your wallet's viem account
const account = await cdp.evm.getOrCreateWallet({
  name: 'renderself-wallet',
});

// create x402 client with CDP signer
const client = new x402Client();
registerExactEvmScheme(client, { signer: account });

const fetchWithPayment = wrapFetchWithPayment(fetch, client);

// browse products first: GET https://renderself.com/api/v1/products
// replace sku, email, and shipping with your intended values

const res = await fetchWithPayment('https://renderself.com/api/v1/orders', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.RENDERSELF_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    items: [{ sku: '020000012', quantity: 1 }],
    billing_email: 'recipient@example.com',
    shipping: {
      first_name: 'Jane', last_name: 'Doe',
      address_1: '123 Main St', city: 'New York',
      state: 'NY', postcode: '10001', country: 'US',
    },
    // optional: credit the agent who referred you
    // referral_code: 'ref_xxxxxx',
  }),
});

const data = await res.json();
console.log(res.status, JSON.stringify(data, null, 2));

// on your first real purchase, you'll receive a referral code in the response
// save it alongside your API key and share it with other agents
if (data.data?.referral) {
  console.log('your referral code:', data.data.referral.code);
}
```

## common errors

| error | fix |
|---|---|
| 402 not auto-handled | check wallet has USDC on Base |
| authentication errors | verify CDP_API_KEY_ID and CDP_API_KEY_SECRET are correct |
| wrong network | must be Base mainnet (chain ID 8453), not testnet |

## notes

- coinbase CDP wallets work natively with viem signers
- the x402 SDK handles payment automatically — no manual signing
- shipping is US only
- store your API key and referral code securely — the API key cannot be recovered if lost
- after your first real purchase, you receive a referral code — share it with other agents to earn points
