Keep EasyPath and the API key on your Node server. The package root uses Node crypto and
WebSockets; it is not a browser entry point. Import @witches-brew/easypath-sdk/helpers in
the browser for amount conversion, picker choices and EIP-1193 transaction formatting.
Your frontend calls your authenticated server. The server owns customer authorization,
validates the selected route against deployment configuration, and stores recovery records.
Browser WebSockets cannot supply the API's bearer header; proxy status through your server
using status, wait or poll. Never put the customer key in a bundle or URL.
The server prepares the quote for the bound sender:
import { solanaDepositBytes } from '@witches-brew/easypath-sdk';
const unsigned = solanaDepositBytes(quote, sender);
// Return these verified bytes to your frontend, encoded as base64 in JSON.
In the browser, Phantom signs a VersionedTransaction, not a raw byte array:
import { VersionedTransaction } from '@solana/web3.js';
const transaction = VersionedTransaction.deserialize(unsignedBytes);
const signed = await window.phantom.solana.signTransaction(transaction);
const signedBytes = signed.serialize();
// Send these bytes to your server for durable storage and relay.
Before this wallet call, record that signing has started. Only prompt while the original intent is pending and within its deadline, and the sender and network still match. After signing, store the exact bytes durably before any relay. If storage fails, stop. Never rebuild or sign another transaction to recover from an interrupted attempt.
On the server, using the original stored quote and sender:
import { verifySolanaDeposit } from '@witches-brew/easypath-sdk';
const check = verifySolanaDeposit(quote, sender, signedBytes, { signed: true });
await journal.saveSigned({ intentId: quote.intentId, signedBytes, signature: check.signature });
const { txHash } = await client.relaySolanaDeposit(quote, sender, signedBytes);
await journal.saveBroadcast({ intentId: quote.intentId, txHash });
These snippets show the browser/server handoff; journal is your durable application store.
Its writes must complete or throw. The relay verifies the signature, fee payer, destination,
token, amount and exact memo. It also checks the returned hash. A relay acknowledgement is not
proof of payment; continue tracking the intent.
If the response is lost, load the saved bytes and reconcile status. An explicit relay retry
must use those same bytes and intent. lastValidBlockHeight is separate from the intent's
deadline. Passing either deadline does not prove that an already signed transaction failed.
For wallet broadcast mode, use the adapter's actual transaction type and documented recovery behavior. A combined sign-and-send call can broadcast before your application stores the signed bytes; record its attempt before calling and retain any returned signature.
Prepare the request on your server after matching its route to configured assets:
import { prepareRobinhoodDeposit } from '@witches-brew/easypath-sdk';
const plan = prepareRobinhoodDeposit(quote, { vaultAddress: config.vault });
// Return { approval?, deposit } bound to this intent and sender.
The plan checks the configured vault, intent, token, amount, native value and payload layout. Any required approval must target that vault for exactly the quoted amount. The payload stays opaque. The SDK does not verify deployed contract code or select a wallet network.
Use the browser helper for an EIP-1193 provider:
import { toEvmWalletTransaction } from '@witches-brew/easypath-sdk/helpers';
const request = toEvmWalletTransaction(plan.deposit, sender);
// After saving the attempt and rechecking account, chain, status and deadline:
const hash = await provider.request({ method: 'eth_sendTransaction', params: [request] });
await journal.saveDepositHash(hash);
If plan.approval exists, send that step first. Save the approval attempt before the wallet
call and its hash immediately afterward. Wait for a successful receipt on the configured
chain. Then recheck sender, chain, status and deadline before saving the deposit attempt and
sending plan.deposit. Never send both in a simple loop.
eth_sendTransaction returns a hash after the wallet sends. It does not return raw signed
bytes. If the wallet disconnects or times out, preserve the attempt and any known hash, then
reconcile the original transaction. Do not deposit while approval is unresolved. Do not invoke
wallet send again simply because no hash was returned.
The application in web/sample demonstrates these steps, a journal, a one-tab lock and recovery
on reload. Its loopback adapter is a development example, not a multi-user backend.