Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Reference — Adapters · Boson Protocol
Skip to content

Adapters

The SDK is wallet-library-agnostic via Web3LibAdapter. Two implementations ship:

EthersAdapter (ethers v5)

import { EthersAdapter } from "@bosonprotocol/ethers-sdk"
import { ethers } from "ethers"
 
const provider = new ethers.providers.JsonRpcProvider(RPC_URL)
const wallet = new ethers.Wallet(PRIVATE_KEY, provider)
const adapter = new EthersAdapter(provider, wallet)  // (provider, signer?)

Constructor signature is EthersAdapter(provider, signer?). The signer is optional for read-only adapters — pass any Signer (ethers Wallet, browser provider's getSigner(), KMS-backed signers) when you need to sign.

viem bridge

import { walletClientToWeb3LibAdapter } from "@bosonprotocol/x402b"
import { createWalletClient, http } from "viem"
import { polygon } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"
 
const wc = createWalletClient({
  account: privateKeyToAccount(PRIVATE_KEY),
  chain: polygon,
  transport: http(),
})
 
const adapter = walletClientToWeb3LibAdapter(wc)

Implementing your own adapter

Web3LibAdapter requires methods to:

  • Get signer address and chain.
  • signMessage, signTypedData.
  • sendTransaction and read receipts.
  • Read on-chain (call, getLogs).

If you have a non-standard signer (HSM, MPC, custom RPC), implement this interface.

Source