Docs Wallets

Wallets

Any injected wallet that announces itself over EIP-6963 or exposes window.ethereum. Photoswap adds Robinhood Chain if the wallet does not know it.

eth_chainId

what chain is the wallet on

≠ 4663

wallet_switchEthereumChain

{ chainId: "0x1237" }

4902 / unrecognised

wallet_addEthereumChain

ROBINHOOD_CHAIN_PARAMS

= 4663 at any point → chainOk, the Buy pill shows the price instead of Switch to Robinhood Chain
ensureRobinhoodChain: check, switch, add. The add step only runs when the wallet says it does not know chain 4663.

Discovery

lib/wallet.ts is framework-free and uses viem only. It listens for eip6963:announceProvider events, dispatches eip6963:requestProvider, and keeps every wallet that announces itself keyed by its rdns. If nothing announces, it falls back to window.ethereum and guesses a name from the usual flags (isRabby, isCoinbaseWallet, isMetaMask).

The last wallet you connected is remembered in localStorage under photoswap.wallet.rdns, so the next visit reconnects silently with eth_accounts. Nothing else is stored.

const { address, connect, disconnect, walletClient, isConnecting, chainOk, switchChain, wallets } = useWallet();

Switching chain

After connecting, ensureRobinhoodChain reads eth_chainId. If it is not 4663 it asks for wallet_switchEthereumChain. A 4902 error (or -32603 with an Unrecognized chain message, which some wallets use) means the chain is unknown, so it follows with wallet_addEthereumChain using these parameters:

{
  chainId: "0x1237",              // 4663
  chainName: "Robinhood Chain",
  nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
  rpcUrls: ["https://rpc.mainnet.chain.robinhood.com"],
  blockExplorerUrls: ["https://robinhoodchain.blockscout.com"],
}

NEXT_PUBLIC_RPC_URL overrides the RPC for both the app's reads and the parameters offered to the wallet. The Connect pill shows Switch to Robinhood Chain until chainOk is true.

Which wallets work

WalletDiscoveryNotes
MetaMaskEIP-6963Adds the chain on first use. Works on desktop and in the mobile in-app browser.
RabbyEIP-6963Shows the simulated balance change before signing, which is a good check on the basket.
Coinbase WalletEIP-6963Extension and in-app browser.
Brave WalletEIP-6963Built into Brave.
Other injectedwindow.ethereumAnything that exposes a provider and supports wallet_addEthereumChain.
WalletConnectNot yetNo relay in this build. Use an in-app browser instead.

You need ETH on Robinhood Chain to buy. Bridging is outside Photoswap; the explorer's bridge page is the usual route.

Errors you will see

walletErrorMessage turns provider errors into one line each:

CauseMessage
Code 4001, user rejectedRequest cancelled in wallet.
Code -32002, request pendingOpen your wallet. A request is already waiting.
insufficient fundsNot enough ETH on Robinhood Chain for this purchase.
Anything elseThe first line of the provider message, cut at 160 characters.

No signatures except the buy

Photoswap never asks for a message signature or an approval. The only thing you sign is the one execute transaction that buys the basket.