@miden-sdk/miden-turnkey
v1.0.2
Published
Miden Turnkey Integration SDK
Downloads
279
Readme
@miden-sdk/miden-turnkey
Miden + Turnkey wallet integration SDK for building secure blockchain applications.
Packages
This monorepo contains the following packages:
| Package | Description |
|---------|-------------|
| @miden-sdk/miden-turnkey | Core SDK for Miden + Turnkey integration |
| @miden-sdk/miden-turnkey-react | React hook for easy integration |
| @miden-sdk/create-miden-turnkey-react | CLI to scaffold new projects |
Quick Start
Option 1: Scaffold a new project
yarn create @miden-sdk/miden-turnkey-react my-app
cd my-app
yarn devOption 2: Add to an existing React project
yarn add @miden-sdk/miden-turnkey @miden-sdk/miden-turnkey-react @miden-sdk/miden-sdk @turnkey/react-wallet-kitimport { TurnkeyProvider } from "@turnkey/react-wallet-kit";
import { useTurnkeyMiden } from "@miden-sdk/miden-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/miden-turnkey @miden-sdk/miden-sdk @turnkey/httpimport { createMidenTurnkeyClient } from "@miden-sdk/miden-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",
type: AccountType.RegularAccountImmutableCode,
storageMode: AccountStorageMode.public(),
}
);Installation
Core SDK
yarn add @miden-sdk/miden-turnkeyPeer Dependencies:
@miden-sdk/miden-sdk@^0.13.0@turnkey/core@^1.8.2@turnkey/http@^3.15.0@turnkey/sdk-browser@^5.13.4
React Hook
yarn add @miden-sdk/miden-turnkey-reactPeer Dependencies:
@miden-sdk/miden-turnkey@^1.0.0@miden-sdk/miden-sdk@^0.13.0@turnkey/react-wallet-kit@^1.6.2react@^18.0.0 || ^19.0.0
Development
Prerequisites
- Node.js 18+
- Yarn 1.22.22
Setup
# Clone the repository
git clone https://github.com/0xPolygonMiden/miden-turnkey.git
cd miden-turnkey
# Install dependencies
yarn install
# Build all packages
yarn buildBuilding Individual Packages
# Root package
yarn build
# React hook package
cd packages/use-miden-turnkey-react
yarn install
yarn buildRunning the Example
cd examples/react
yarn install
yarn 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 seedaccountSeed- Account derivation seedtype- Account type (RegularAccountImmutableCode, etc.)storageMode- Storage mode (public or private)
Returns
{
client: WebClient;
accountId: string;
}useTurnkeyMiden(nodeUrl, storageMode?, opts?)
React hook for Miden + Turnkey integration. See @miden-sdk/miden-turnkey-react README.
Examples
See the examples/react directory for a complete Next.js example application.
License
ISC
