@miden-sdk/turnkey
v0.17.3
Published
Miden Turnkey Integration SDK
Readme
@miden-sdk/turnkey
Miden + Turnkey wallet integration SDK for building secure blockchain applications.
Packages
This monorepo contains the following packages:
| Package | Description |
|---------|-------------|
| @miden-sdk/turnkey | Core SDK for Miden + Turnkey integration |
| @miden-sdk/turnkey-react | React hook for easy integration |
| @miden-sdk/create-turnkey-react | CLI to scaffold new projects |
Quick Start
Option 1: Scaffold a new project
yarn create @miden-sdk/turnkey-react my-app
cd my-app
yarn devOption 2: Add to an existing React project
yarn add @miden-sdk/turnkey @miden-sdk/turnkey-react @miden-sdk/miden-sdk @turnkey/react-wallet-kitimport { TurnkeyProvider } from "@turnkey/react-wallet-kit";
import { useTurnkeyMiden } from "@miden-sdk/turnkey-react";
function App() {
return (
<TurnkeyProvider config={turnkeyConfig}>
<MidenApp />
</TurnkeyProvider>
);
}
function MidenApp() {
const { client, accountId } = useTurnkeyMiden(
"https://rpc.miden.io",
"public",
{ accountSeed: "my-seed" }
);
if (!client) return <div>Loading...</div>;
return <div>Account: {accountId}</div>;
}Option 3: Use the core SDK directly
yarn add @miden-sdk/turnkey @miden-sdk/miden-sdk @turnkey/httpimport { createMidenTurnkeyClient } from "@miden-sdk/turnkey";
import { TurnkeyClient } from "@turnkey/http";
const turnkeyClient = new TurnkeyClient({
baseUrl: "https://api.turnkey.com",
// ... auth config
});
const { client, accountId } = await createMidenTurnkeyClient(
{
client: turnkeyClient,
organizationId: "your-org-id",
account: walletAccount,
},
{
endpoint: "https://rpc.miden.io",
noteTransportUrl: "https://transport.miden.io",
accountSeed: "my-seed",
storageMode: AccountStorageMode.public(),
}
);Installation
Core SDK
yarn add @miden-sdk/turnkeyPeer Dependencies:
@miden-sdk/miden-sdk@^0.16.2
@turnkey/core, @turnkey/http and @turnkey/sdk-browser are regular
dependencies of this package, so you do not install them yourself.
React Hook
yarn add @miden-sdk/turnkey-reactPeer Dependencies:
@miden-sdk/turnkey@^0.16.2@miden-sdk/miden-sdk@^0.16.2@miden-sdk/react@^0.16.2@turnkey/core@^1.8.2@turnkey/react-wallet-kit@^1.6.2@turnkey/sdk-browser@^5.13.4react@^18.0.0 || ^19.0.0
Development
Prerequisites
- Node.js 20+
- pnpm 9+
Setup
# Clone the repository
git clone https://github.com/0xMiden/web-sdk.git
cd web-sdk
# Install dependencies
pnpm install
# Build all packages
pnpm -r buildBuilding Individual Packages
# Core package
pnpm --filter @miden-sdk/turnkey run build
# React hook package
pnpm --filter @miden-sdk/turnkey-react run buildRunning the Example
cd packages/turnkey/core/examples/react
pnpm install
pnpm devAPI Reference
createMidenTurnkeyClient(turnkeyConfig, opts)
Creates a Miden client with Turnkey signing integration.
Parameters
turnkeyConfig- Turnkey configurationclient- TurnkeyClient or TurnkeyBrowserClient instanceorganizationId- Your Turnkey organization IDaccount- WalletAccount to use for signing
opts- Miden optionsendpoint- Miden node RPC URLnoteTransportUrl- Note transport service URLseed- Client seed (Uint8Array)accountSeed- Account derivation seedstorageMode- Storage mode (AccountStorageMode.public()orAccountStorageMode.private()). Required; every other option is optional.
Returns
Promise<{
client: MidenClient;
accountId: string;
}>useTurnkeyMiden(nodeUrl, storageMode?, opts?)
React hook for Miden + Turnkey integration. See @miden-sdk/turnkey-react README.
Examples
See the examples/react directory for a complete Next.js example application.
License
ISC
