Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.0xkey.io/llms.txt

Use this file to discover all available pages before exploring further.

Steps using @0xkey-io/react-wallet-kit

1

Initialize the React Provider

import { ZeroXKeyProvider } from "@0xkey-io/react-wallet-kit";
const oxkeyConfig = {
  apiBaseUrl: "https://api.0xkey.io",
  defaultOrganizationId: process.env.OXKEY_ORGANIZATION_ID, // prefix with NEXT_PUBLIC for NextJS
  rpId: process.env.RPID, // your application's domain
  iframeUrl: "https://auth.oxkey.com"
}

...

<div className="App">
  <ZeroXKeyProvider config={oxkeyConfig}>
  // Rest of app ...
  </ZeroXKeyProvider>
</div>
2

Initialize an Ethers Provider and 0xkey Signer using the Passkey Client

import { ethers } from "ethers";
import { ZeroXKeySigner } from "@0xkey-io/ethers";

import { useZeroXKey } from "@0xkey-io/react-wallet-kit";
const { oxkey, passkeyClient } = useZeroXKey();

const provider = new ethers.JsonRpcProvider(<provider api url>);
const currentUser = await oxkey.getCurrentUser();
const oxkeySigner = new ZeroXKeySigner({
  client: passkeyClient,
  organizationId: currentUser.organization.organizationId,
  signWith: "<wallet address to sign with>"
})
const connectedSigner = oxkeySigner.connect(provider);
3

Call `sendTransaction` with the 0xkey Signer

const transactionRequest = {
  to: "<destination address>",
  value: ethers.parseEther("<amount to send>"),
  type: 2,
};
const sendTransaction = await connectedSigner.sendTransaction(transactionRequest);
For Viem or Solana signing, see @0xkey-io/viem and @0xkey-io/solana, or the GitHub examples.