One WalletAdapter interface for signing and sending transactions through managed providers (Privy, Fireblocks, Turnkey, Bankr) or a local private key.
@opensea/sdk, @opensea/cli, @opensea/tool-sdk, and opensea-skill all sign through this interface, so a provider implemented here works in each of them.
- Managed providers (Privy, Fireblocks, Bankr) handle gas and nonces server-side. Turnkey and PrivateKey fetch them from an RPC endpoint.
createWalletFromEnv()picks a provider from environment variables.- Optional bridges turn an adapter into a viem
WalletClient(recommended) or, for projects already on ethers, an ethersSigner. - The core depends only on Web Crypto and
@noble/hashes/@noble/curves.viem,ethers, and@privy-io/nodeare optional peer dependencies; installviemto use the viem bridge.
npm install @opensea/wallet-adapters
# or
pnpm add @opensea/wallet-adaptersimport {
createWalletFromEnv,
requireEvmAdapter,
} from "@opensea/wallet-adapters"
// Auto-detects the provider from environment variables.
// Priority: Privy > Fireblocks > Turnkey > Bankr > PrivateKey
const wallet = requireEvmAdapter(createWalletFromEnv(), "quick start")
const address = await wallet.getAddress()
const result = await wallet.sendTransaction({
to: "0x0000000000000000000000000000000000000001",
data: "0x",
value: "0",
chainId: 8453,
})
console.log(`${address} sent ${result.hash}`)This is examples/quick-start.ts, which CI type-checks with the other examples.
createWalletFromEnv() returns an EVM wallet by default. Pass { chainType: "svm" } for a Solana wallet, which only Privy supports (it reads PRIVY_SVM_WALLET_ID instead of PRIVY_WALLET_ID). The return type covers both chain families, so narrow it with requireEvmAdapter or isEvmAdapter before calling EVM-only methods.
Each adapter has a fromEnv() constructor that reads its own environment variables
(examples/adapters.ts).
| Adapter | How it signs | Required variables |
|---|---|---|
PrivyAdapter |
Server-side wallet through Privy's API. Privy estimates gas and manages nonces. | PRIVY_APP_ID, PRIVY_APP_SECRET, PRIVY_WALLET_ID |
FireblocksAdapter |
MPC custody through the Fireblocks API. | FIREBLOCKS_API_KEY, FIREBLOCKS_API_SECRET, FIREBLOCKS_VAULT_ID |
TurnkeyAdapter |
HSM-backed signing with P-256 stamp authentication. | TURNKEY_API_PUBLIC_KEY, TURNKEY_API_PRIVATE_KEY, TURNKEY_ORGANIZATION_ID, TURNKEY_WALLET_ADDRESS, TURNKEY_RPC_URL |
BankrAdapter |
Agent wallet through Bankr's Wallet API. One API key authenticates, and Bankr handles gas, nonces, and broadcast. | BANKR_API_KEY |
PrivateKeyAdapter |
Local signing for development and testing. | PRIVATE_KEY |
PrivateKeyAdapter signs EIP-1559 transactions itself and broadcasts them with
eth_sendRawTransaction, so any RPC for the target chain works and the node never sees the key.
It also reads two optional variables: RPC_URL, which it needs to send transactions (nonce, gas
and fees come from it), and WALLET_ADDRESS, which skips address derivation and is not checked
against the key.
walletAdapterToViemClient(wallet, chain, rpcUrl) from @opensea/wallet-adapters/viem returns a
standard viem WalletClient whose account is always set (typed AdapterWalletClient<TChain>, so
client.account.address needs no check). Transactions (eth_sendTransaction), typed data
(eth_signTypedData_v4) and messages (personal_sign) go through the adapter, and every other
request goes to rpcUrl. signTypedData and signMessage throw when the adapter does not support
them. examples/bridges.ts uses it.
import { createWalletFromEnv } from "@opensea/wallet-adapters"
import { walletAdapterToViemClient } from "@opensea/wallet-adapters/viem"
import { base } from "viem/chains"
const walletClient = await walletAdapterToViemClient(
createWalletFromEnv(),
base,
"https://mainnet.base.org",
)Pass the client to OpenSeaSDK from @opensea/sdk/viem as walletClient, next to a
publicClient for the same chain.
For a project already on ethers v6, walletAdapterToEthersSigner(wallet, provider) from
@opensea/wallet-adapters/ethers returns a standard ethers Signer
(examples/ethers-bridge.ts). Both bridges throw WrongChainTypeError
when given a Solana wallet.
provider can come from either ethers build, and new OpenSeaSDK(signer, ...) from @opensea/sdk accepts the signer in ESM and CommonJS projects. The bridge is typed against ethers' ESM declarations, which TypeScript treats as unrelated to the CommonJS ones. An API typed with the CommonJS declarations (Contract in a CommonJS project) rejects the signer at compile time even though it works at runtime. Cast it to that API's parameter type, as the ethers example does for Contract: signer as unknown as ContractRunner.
Each adapter declares what it supports, so callers can check wallet.capabilities before calling
an optional method such as signMessage:
| Capability | Privy | Fireblocks | Turnkey | Bankr | PrivateKey |
|---|---|---|---|---|---|
signMessage |
true | true | true | true | true |
signTypedData |
true | true | true | true | true |
managedGas |
true | true | false | true | false |
managedNonce |
true | true | false | true | false |
Set onRequest and onResponse on an adapter to trace its calls. onResponse also receives the
call's duration in milliseconds. examples/capabilities-and-observability.ts
shows both hooks and a capability check.
Implement EvmWalletAdapter (or SvmWalletAdapter for Solana), as
examples/custom-adapter.ts does, then register it in
createWalletFromEnv() in src/factory.ts so the CLI and tool-sdk detect it from environment
variables.
Read-only mirror of a private monorepo, updated on each release. Pull requests are welcome, and we bring accepted changes into the monorepo.
Found a vulnerability? Report it through OpenSea's Bugcrowd program at https://bugcrowd.com/engagements/opensea rather than opening a public issue. See SECURITY.md.
MIT