3️⃣API Examples

Before integrating, ensure you have:

  1. ✅ A wallet that supports the target blockchain (Base, Polygon, Avalanche, or Solana)

  2. ✅ USDC tokens for API payments (if required by the endpoint)

  3. ✅ An HTTP client library (axios, fetch, etc.)

  4. ✅ Web3 library for transaction signing (ethers.js, web3.js, or @solana/web3.js)

Integration Steps

Step 1: Send Initial Query

Send a POST request with your natural language command:

const response = await fetch("http://api.hashhunter.app/api/process", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    messages: [
      {
        role: "user",
        content: "Send 10 USDC to 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
      },
    ],
    wallet: "0xYourWalletAddress",
    chain: "base",
  }),
});

const data = await response.json();
console.log(data.operationId); // Save this for next steps

Response:


Step 2: Request Payment Information

Using the operationId from Step 1, request payment details:

Response (402 Payment Required):


Step 3: Make Payment (X402 Protocol)

Generate the X402 payment proof. This typically involves:

  1. Creating a payment transaction to the payTo address

  2. Including the required metadata

  3. Signing with your wallet

  4. Generating the payment proof string

Note: The X402 payment implementation depends on your client library. Refer to X402 Documentationarrow-up-right for detailed implementation.


Step 4: Verify Payment & Get Transaction

Send the payment proof to retrieve your transaction:

Response:


Step 5: Execute Transaction

Execute the transaction using your Web3 library:

For EVM Chains (Base, Polygon, Avalanche)

For Solana

Last updated