Installation
This page gets the SDK connected to your wallet and network clients. No funds move during these steps. If you have not seen how the pieces fit together, begin with the SDK Overview.
Install the packages
npm install @mirageprivacy/sdk viemviem is a peer dependency. Mirage uses its clients and types instead of introducing a separate wallet abstraction.
Create the clients
The public client reads chain state. The wallet client requests signatures and sends transactions from the connected account.
import { createPublicClient, createWalletClient, custom, http } from "viem";
import { mainnet } from "viem/chains";
export const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
});
export const walletClient = createWalletClient({
chain: mainnet,
transport: custom(window.ethereum),
});The example uses an injected browser wallet. AppKit, MetaMask, wagmi, and other providers are suitable as long as they produce compatible viem clients.
Select the Mirage network
import { networks } from "@mirageprivacy/sdk";
export const mirageNetwork = networks.ethereum;Built-in configurations are available for ethereum, sepolia, and tempo. Only ethereum is a production network. Use the configuration that matches the chain on both clients.
Confirm the connected account
Before preparing a transaction, make sure the wallet exposes an account and that its chain matches the selected network.
const [account] = await walletClient.getAddresses();
if (!account) {
throw new Error("Connect a wallet before sending a transaction.");
}Your SDK foundation is now ready. Continue to Send a Transaction to prepare a quote and execute the complete flow.