# render_self — solana native wallet guide

for agents paying with USDC on Solana using a keypair file or secret key.

## prerequisites

```bash
npm install @x402/fetch @x402/core @x402/svm @solana/kit
```

## credentials you need

| credential | where to get it |
|---|---|
| SOLANA_SECRET_KEY | your 64-byte keypair (base58 or JSON array) |
| RENDERSELF_API_KEY | returned at registration (POST /api/v1/agents/register) |

your wallet must hold USDC on Solana mainnet (mint: `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v`).

**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 Solana USDC automatically. no SDK needed:
`https://kibble.sh/pay?toChain=1151111081099710&toToken=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&toAddress=YOUR_WALLET`

**important:** your wallet also needs a small amount of SOL (~0.01) for transaction fees.

## full working example

```javascript
import { wrapFetchWithPayment } from '@x402/fetch';
import { x402Client } from '@x402/core/client';
import { registerExactSvmScheme } from '@x402/svm/exact/client';
import { createKeyPairSignerFromBytes } from '@solana/kit';

// load your secret key (64-byte Uint8Array)
// if you have a JSON array file: JSON.parse(fs.readFileSync('keypair.json'))
const secretKey = new Uint8Array(JSON.parse(process.env.SOLANA_SECRET_KEY));
const signer = await createKeyPairSignerFromBytes(secretKey);

console.log('wallet address:', signer.address);

const client = new x402Client();
registerExactSvmScheme(client, {
  signer,
  networks: ['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'],
});

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
if (data.data?.referral) {
  console.log('your referral code:', data.data.referral.code);
}
```

## wallet setup

if you don't have a Solana wallet yet:

```javascript
import { generateKeyPairSigner } from '@solana/kit';

const signer = await generateKeyPairSigner();
console.log('address:', signer.address);
// export and save the secret key bytes securely
```

or use the Solana CLI:

```bash
solana-keygen new --outfile wallet.json
solana address -k wallet.json
```

then fund it with USDC on Solana mainnet and a small amount of SOL for fees.

## common errors

| error | fix |
|---|---|
| `InvalidAccountData` simulation error | the receiving wallet needs a USDC token account (ATA) — this is a seller-side issue, not yours |
| `feePayer is required` | the x402 facilitator provides the feePayer — make sure you're using the SDK, not manual transfers |
| 402 not auto-handled | check wallet has USDC on Solana mainnet |
| insufficient SOL | wallet needs ~0.01 SOL for transaction fees |
| `Cannot find package '@solana/kit'` | run `npm install @solana/kit @x402/svm` |
| wrong network | must be Solana mainnet, not devnet |

## notes

- the x402 SDK handles the full 402 → sign → retry flow automatically
- the facilitator pays transaction fees (feePayer) — you only need SOL as a safety margin
- you never construct payment headers manually
- shipping is US only
- store your API key and referral code securely — the API key cannot be recovered if lost
- render_self also accepts USDC on Base — see the native (Base) wallet guide if you prefer EVM
