Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The `aud` claim must be set to your Alchemy-provided audience ID. You can obtain
## Implementation Guide

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
## Using React Hooks

### Step 1: Install Dependencies
Expand Down Expand Up @@ -170,7 +170,7 @@ The `aud` claim must be set to your Alchemy-provided audience ID. You can obtain
```
</Tab>

<Tab title="APIs">
<Tab title="API" language="bash">
## Authenticating Users with a JWT token

**Endpoint:** `POST https://api.g.alchemy.com/signer/v1/auth-jwt`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Email magic link authentication is a two-step process:
</Tip>

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
## Implementation Options

You can implement Email Magic Link authentication in two ways:
Expand Down Expand Up @@ -308,7 +308,7 @@ Email magic link authentication is a two-step process:
```
</Tab>

<Tab title="JavaScript">
<Tab title="JavaScript" language="typescript">
## Other Javascript Frameworks

Email magic link authentication allows you to log in and sign up users using an email address. Your users will receive a link in their inbox which will redirect them to your site (configured in the dashboard) to complete login.
Expand Down
4 changes: 2 additions & 2 deletions fern/wallets/pages/authentication/login-methods/email-otp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Email OTP (One-Time Password) authentication is a two-step process:
2. The user enters the 6-digit code they receive in their inbox to complete authentication

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
## Overview

You can implement Email OTP authentication in two ways:
Expand Down Expand Up @@ -484,7 +484,7 @@ Email OTP (One-Time Password) authentication is a two-step process:
</CodeBlocks>
</Tab>

<Tab title="JavaScript">
<Tab title="JavaScript" language="typescript">
## Other Javascript Frameworks

Email OTP authentication allows you to log in and sign up users using an email address. Your users will receive six-digit code in their inbox which they can enter in your site to complete login.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Passkeys provide a secure, passwordless authentication method that can be used t
<Markdown src="../../../shared/passkey-email-warning.mdx" />

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
## Implementation Options

You can implement Passkey Signup authentication in two ways:
Expand Down Expand Up @@ -437,7 +437,7 @@ Passkeys provide a secure, passwordless authentication method that can be used t
```
</Tab>

<Tab title="JavaScript">
<Tab title="JavaScript" language="typescript">
## Other Javascript Frameworks

It is possible to create wallets for users using just a passkey. This is useful for creating wallets for users if you don't want to go through the email OTP or magic link flow.
Expand Down
4 changes: 2 additions & 2 deletions fern/wallets/pages/authentication/login-methods/sms-login.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pricing varies by country and requires specific area codes to be enabled for you
## Implementation

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
<Info>
SMS auth is not yet supported with pre-built UI components. Please follow [this guide](/wallets/pages/react/react-hooks) to set up custom UI and configure authentication with hooks.
</Info>
Expand Down Expand Up @@ -220,7 +220,7 @@ Pricing varies by country and requires specific area codes to be enabled for you
```
</Tab>

<Tab title="Javascript">
<Tab title="JavaScript" language="typescript">
<Info>Ensure you've set up your project by following [this](/wallets/pages/core/quickstart) guide first.</Info>

```ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Social login authentication allows users to authenticate using OAuth providers l
2. **Popup flow**: Opens the provider's login page in a popup window without leaving your application

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
## Prerequisites

Before implementing social login in your application, you need to configure your Smart Wallets dashboard and application:
Expand Down Expand Up @@ -199,7 +199,7 @@ Social login authentication allows users to authenticate using OAuth providers l
</Tip>
</Tab>

<Tab title="JavaScript">
<Tab title="JavaScript" language="typescript">
## Other Javascript Frameworks

Social login authentication allows you to log in and sign up users using an OAuth provider, such as Google Sign-In or Facebook Login. You can also configure custom providers through Auth0.
Expand Down
54 changes: 2 additions & 52 deletions fern/wallets/pages/concepts/smart-account-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,7 @@ The [`SmartWalletClient`](https://github.com/alchemyplatform/aa-sdk/blob/b8dad09
## Implementation

<Tabs>
<Tab title="React">
The [`useSmartAccountClient`](/docs/wallets/reference/account-kit/react/hooks/useSmartAccountClient) hook provides access to your smart account client using the API key and policy ID settings from \[`createConfig`]/docs/wallets/react/quickstart/ui-customization).

React hooks only support Alchemy Signer, so ensure you [set up your environment](/docs/wallets/react/quickstart/existing-project) and app integration before using the client.

<Note>
Don't call methods like `client.sendUserOperation()` directly on the client. Instead, use React hooks like [`useSendCalls`](/docs/wallets/reference/account-kit/react/hooks/useSendCalls) which provide better state management and error handling.
</Note>

```tsx twoslash
import React from "react";
import { useSmartAccountClient, useSendCalls } from "@account-kit/react";

const { client } = useSmartAccountClient({});

const { sendCalls, isSendingCalls, sendCallsResult } = useSendCalls({
client,
});
```
</Tab>

<Tab title="Javascript">
<Tab title="JavaScript" language="typescript">
Use the [`createSmartWalletClient`](/docs/wallets/reference/account-kit/wallet-client/functions/createSmartWalletClient) function to create a smart wallet client.

1. Replace the placeholders
Expand Down Expand Up @@ -77,7 +56,7 @@ The [`SmartWalletClient`](https://github.com/alchemyplatform/aa-sdk/blob/b8dad09
```
</Tab>

<Tab title="API">
<Tab title="API" language="bash">
When using the wallet [API](/docs/wallets/smart-wallet-quickstart/api), you don't need to define a client - send requests directly to the API endpoints.
</Tab>
</Tabs>
Expand All @@ -94,24 +73,6 @@ The [`SmartWalletClient`](https://github.com/alchemyplatform/aa-sdk/blob/b8dad09
[here](/docs/wallets/smart-contracts/other-accounts/modular-account/upgrading-to-modular-account).
</Tip>

**React and React Native**

Override the default account type using the `type` parameter:

* `type` (string) - Defines the smart account type. Options:
* `"ModularAccountV2"` (recommended and default)
* `"LightAccount"`
* `"MultiOwnerLightAccount"`

```tsx twoslash
import React from "react";
import { useSmartAccountClient } from "@account-kit/react";

const { client } = useSmartAccountClient({
type: "LightAccount",
});
```

**Javascript**

Specify the account type when calling `requestAccount` using the `creationHint` parameter. See all parameter [options](/docs/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-request-account#request.body.requestAccountRequest.creationHint).
Expand Down Expand Up @@ -141,17 +102,6 @@ The [`SmartWalletClient`](https://github.com/alchemyplatform/aa-sdk/blob/b8dad09
<Accordion title="Connect to an existing account address">
By default, account addresses are deterministically generated from the signer address. To connect to an existing account that doesn't match the deterministic address of your signer, specify the account address when creating the client.

**React & React Native**

```tsx twoslash
import React from "react";
import { useSmartAccountClient } from "@account-kit/react";

const { client } = useSmartAccountClient({
accountAddress: "0xYOUR_SMART_ACCOUNT_ADDR",
});
```

**Javascript**

Pass the address to the `createSmartWalletClient` directly rather than calling `requestAccount`.
Expand Down
10 changes: 2 additions & 8 deletions fern/wallets/pages/guide-template.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@ Example:
## Implementation

<Tabs>
<Tab title="React">
<Info>Required SDK version: ^v4.59.1</Info>

<Markdown src="react.mdx" />
</Tab>

<Tab title="Javascript">
<Tab title="JavaScript" language="typescript">
<Info>Required SDK version: ^v4.59.1</Info>

<Markdown src="client.mdx" />
</Tab>

<Tab title="API">
<Tab title="API" language="bash">
See the [`wallet_prepareCalls` API
reference](/docs/wallets/api/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-prepare-calls)
for full descriptions of the parameters used in the following examples.
Expand Down
2 changes: 1 addition & 1 deletion fern/wallets/pages/react/mfa/setup-mfa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ slug: wallets/react/mfa/setup-mfa
---

<Tabs>
<Tab title="React">
<Tab title="React" language="react">
With Smart Wallets, multi-factor authentication (MFA) uses authenticator apps—like Google Authenticator, Authy, or Microsoft Authenticator—to generate a Time-based One-Time Password (TOTP).

By requiring both a user's primary login (e.g., email OTP, magic link, or social login) and a TOTP from their authenticator app, your application gains an extra layer of security.
Expand Down
165 changes: 1 addition & 164 deletions fern/wallets/pages/react/pay-gas-with-any-token.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,170 +17,7 @@ Gas fees paid in the native gas token can feel foreign to users that primarily h
<Markdown src="../../shared/sponsor-gas-erc20-create-policy.mdx" />

<Tabs>
<Tab title="React">
## 2. Add the policy to your global config

```ts twoslash config.ts
import { createConfig } from "@account-kit/react";
import { sepolia } from "@account-kit/infra";

export const config = createConfig({
apiKey: "ALCHEMY_API_KEY",
chain: sepolia,
policyId: "GAS_MANAGER_POLICY_ID", // your policy
policyToken: {
address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", // USDC_ADDRESS on sepolia (can be any ERC-20 token address enabled in your policy)
maxTokenAmount: 10_000_000n, // Safety limit. If using USDC, this is 10 USDC (10 * 10^6).
},
});
```

All `UserOperations` sent with the hooks will now be paid with the token configured above.

<Warning>
Be sure to use version **4.54.1** or later of the Account Kit SDK.
</Warning>

## 3. Send a sponsored UserOperation

```tsx twoslash
import React from "react";
import {
useSmartAccountClient,
useSendUserOperation,
} from "@account-kit/react";
import { sepolia, getAlchemyPaymasterAddress } from "@account-kit/infra";
import { encodeFunctionData, parseAbi } from "viem";

export default function PayWithUsdcButton() {
const { client, isLoadingClient } = useSmartAccountClient({});
const erc20Abi = parseAbi([
"function approve(address spender, uint256 amount) public returns (bool)",
]);
const paymasterAddress = getAlchemyPaymasterAddress(sepolia, "0.7.0");

return (
<button
onClick={() =>
client!.sendUserOperation({
uo: [
{
// approve call
target: tokenAddress,
data: encodeFunctionData({
abi: erc20Abi,
functionName: "approve",
args: [paymasterAddress, maxTokenAmount],
}) as `0x${string}`,
},
{
target: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045", // TARGET_ADDRESS
data: "0x",
value: 0n,
},
],
})
}
disabled={isLoadingClient}
>
Send USDC-sponsored operation
</button>
);
}
```

<Tip>
When performing ERC-20 sponsorship, be sure to use the `sendUserOperation`
method on a client. Support for the `useSendUserOperation` hook is coming
soon.
</Tip>

### 4 (Optional) Override on a single client

If you only want specific operations to use the policy, you can specify it on a dedicated client instead of setting it globally.

```tsx twoslash
const { client } = useSmartAccountClient({
policyId: "GAS_MANAGER_POLICY_ID",
policyToken: {
address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", // USDC_ADDRESS on sepolia (can be any ERC-20 token address enabled in your policy)
maxTokenAmount: 10_000_000n, // Safety limit. If using USDC, this is 10 USDC (10 * 10^6).
},
});
```

Then use `client.sendUserOperation()` to send UserOperations.

</Tab>
<Tab title="React Native">
## 2. Set the Policy ID globally

When creating your Account Kit config, you can optionally pass in a Gas Policy ID. This will enable all UOs sent by the `useSendUserOperation` hook to be sponsored by the policy you created.

Copy it and then replace the `GAS_MANAGER_POLICY_ID` in the snippet below.

<Tip>
Remember to replace `ALCHEMY_API_KEY` with your Alchemy API key. If you don't
have one yet, you can create an API key on the [Alchemy
dashboard](https://dashboard.alchemy.com/signup/?a=aa-docs).
</Tip>

```ts twoslash config.ts
// @noErrors
import { createConfig } from "@account-kit/react-native";
import { sepolia } from "@account-kit/infra";

export const config = createConfig({
apiKey: "ALCHEMY_API_KEY",
chain: sepolia,
policyId: "GAS_MANAGER_POLICY_ID", // [!code ++]
});
```

Now you can follow the guide for [Sending user operations](/wallets/react-native/using-smart-accounts/send-user-operations) to send sponsored UOs from your smart account!

## 3. Set the gas policy ID per UserOperation

If you want more control over which UOs are sponsored, then you can set the policy ID on a specific instance of the `Smart Account Client` returned by the `useSmartAccountClient()` hook.

```tsx twoslash
import React from "react";
import { View, Pressable, Text } from "react-native";
import {
useSmartAccountClient,
useSendUserOperation,
} from "@account-kit/react-native";

export default function MyComponent() {
const { client } = useSmartAccountClient({
policyId: "GAS_MANAGER_POLICY_ID",
});
const { sendUserOperation } = useSendUserOperation({ client });

return (
<View>
<Pressable
onPress={() =>
sendUserOperation({
uo: {
target: "0xTARGET_ADDRESS",
data: "0x",
value: 0n,
},
})
}
>
<View>
<Text>Send Sponsored User Operation</Text>
</View>
</Pressable>
</View>
);
}
```

</Tab>
<Tab title="Other Javascript">
<Tab title="Javascript">
## 2. Create a smart Account Client

Now you can create a Smart Account Client which is configured to sponsor gas.
Expand Down
Loading
Loading