Skip to main content
Before you start with the demo, you will need a wallet on one of the supported networks.

Networks

Corbits currently supports the following chain/network combinations:
  • solana-mainnet-beta
  • base-mainnet
  • polygon-mainnet

Wallets

To use the demo, you will need a wallet on one of the networks supported by x402. For more on wallets, see How to set up a Wallet

Simple Client using @faremeter/rides

@faremeter/rides is the easiest way start using x402. You just need a wallet and and endpoint! This example allows you to access an x402 endpoint and pay with a wallet on solana, base, or polygon. For complete instructions on setting up your development environment see setup.

1. - Install required packages

You will need @faremeter/rides, @faremeter/types and dotenv
   pnpm add @faremeter/rides @faremeter/types dotenv

2. - Create your script

Paste the demo script into rides.ts:
   import "dotenv/config";
   import { payer } from "@faremeter/rides";

   await payer.addLocalWallet(process.env.SOLANA_PRIVATE_KEY);
   await payer.addLocalWallet(process.env.EVM_PRIVATE_KEY);

   const endpoint = process.env.ENDPOINT ?? "https://helius.api.corbits.dev";

   const req = await payer.fetch(endpoint, {
     method: "POST",
     headers: { "Content-Type": "application/json" },
     body: JSON.stringify({
       jsonrpc: "2.0",
       id: 1,
       method: "getBlockHeight"
     })
   });

   console.log(`status: ${req.statusText} (${req.status})`);

   if (req.status === 200) {
     console.log(await req.json());
   }

3. Provide your credentials

cat <<'EOF' > .env
SOLANA_PRIVATE_KEY=base64-or-JSON-private-key
EVM_PRIVATE_KEY=0xYOUR_PRIVATE_KEY
ENDPOINT=https://helius.api.corbits.dev
EOF

4. Run the demo

pnpm tsx rides.ts
you should see something like:
$ pnpm tsx rides.ts
bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
status: OK (200)
{ jsonrpc: '2.0', result: 357792730, id: 1 }

Next steps