diff --git a/site/.vitepress/config.ts b/site/.vitepress/config.ts index 819882465a..a9ddcfbd73 100644 --- a/site/.vitepress/config.ts +++ b/site/.vitepress/config.ts @@ -101,6 +101,7 @@ export default defineConfig({ { text: "Capsule", link: "/capsule" }, { text: "Lit Protocol", link: "/lit" }, { text: "Particle Network", link: "/particle-network" }, + { text: "Dfns", link: "/dfns" }, { text: "Externally Owned Account (EOA)", link: "/eoa" }, { text: "Using Your Own", link: "/custom-signer" }, ], diff --git a/site/overview/introduction.md b/site/overview/introduction.md index 2effbe3bb3..4d14e44b92 100644 --- a/site/overview/introduction.md +++ b/site/overview/introduction.md @@ -64,7 +64,7 @@ To learn how to deploy a `LightAccount`, see [Light Account](/smart-accounts/acc ### Signers -A Signer is responsible for securely managing the private key and signing transaction requests on the smart account. Account Kit supports many popular wallet signers including [Magic](/smart-accounts/signers/guides/magic), [web3auth](/smart-accounts/signers/guides/web3auth), [Turnkey](/smart-accounts/signers/guides/turnkey), [Privy](/smart-accounts/signers/guides/privy), [Dynamic](/smart-accounts/signers/guides/dynamic), [Fireblocks](/smart-accounts/signers/guides/fireblocks), [Portal](/smart-accounts/signers/guides/portal), [Capsule](/smart-accounts/signers/guides/capsule) and [Lit Protocol](/smart-accounts/signers/guides/lit). It also supports self-custodial wallets like MetaMask or Ledger. +A Signer is responsible for securely managing the private key and signing transaction requests on the smart account. Account Kit supports many popular wallet signers. It also supports self-custodial wallets like MetaMask or Ledger. To get started with a Signer, read the doc: [How to Choose a Signer](/smart-accounts/signers/choosing-a-signer). diff --git a/site/overview/why-account-kit.md b/site/overview/why-account-kit.md index 5db30bef7a..591b0deb4f 100644 --- a/site/overview/why-account-kit.md +++ b/site/overview/why-account-kit.md @@ -65,9 +65,9 @@ Streamline your sign up flow with simple web2 login options supported by Account - Self-custodial wallets like MetaMask or Ledger - and more -Account Kit integrates all the leading wallet Signers with bespoke integration guides for [Magic](/smart-accounts/signers/guides/magic), [web3auth](/smart-accounts/signers/guides/web3auth), [Turnkey](/smart-accounts/signers/guides/turnkey), [Privy](/smart-accounts/signers/guides/privy), [Dynamic](/smart-accounts/signers/guides/dynamic), [Fireblocks](/smart-accounts/signers/guides/fireblocks), [Portal](/smart-accounts/signers/guides/portal), [Capsule](/smart-accounts/signers/guides/capsule) and [Lit Protocol](/smart-accounts/signers/guides/lit). Account Kit even supports self-custodial wallets like MetaMask or Ledger. Users can even change their Signer later via Account Kit’s [ownership transfer](/tutorials/transferring-ownership) functionality. +Account Kit integrates all the leading wallet Signers with integration guides that you can find [here](/smart-accounts/signers/choosing-a-signer). Account Kit even supports self-custodial wallets like MetaMask or Ledger. Users can even change their Signer later via Account Kit’s [ownership transfer](/tutorials/transferring-ownership) functionality. -Learn [how to choose the right Signer for your use case in this doc](/smart-accounts/signers/choosing-a-signer). +Learn [how to choose and integrate the right Signer for your use case in this doc](/smart-accounts/signers/choosing-a-signer). ## Sponsor gas diff --git a/site/smart-accounts/signers/choosing-a-signer.md b/site/smart-accounts/signers/choosing-a-signer.md index 0687106674..ab68fc91d8 100644 --- a/site/smart-accounts/signers/choosing-a-signer.md +++ b/site/smart-accounts/signers/choosing-a-signer.md @@ -48,18 +48,7 @@ The Signer plays a crucial role in your app because it controls the user’s sma ## Supported Signers -Account Kit is compatible with any EIP-1193 provider. Many of the most popular signers can be configured in minutes through our integration guides below: - -- [Magic](/smart-accounts/signers/guides/magic) -- [web3auth](/smart-accounts/signers/guides/web3auth) -- [Turnkey](/smart-accounts/signers/guides/turnkey) -- [Privy](/smart-accounts/signers/guides/privy) -- [Dynamic](/smart-accounts/signers/guides/dynamic) -- [Fireblocks](/smart-accounts/signers/guides/fireblocks) -- [Portal](/smart-accounts/signers/guides/portal) -- [Capsule](/smart-accounts/signers/guides/capsule) -- [Lit Protocol](/smart-accounts/signers/guides/lit) -- [Self-custodial wallets like MetaMask or Ledger](/smart-accounts/signers/guides/eoa) +Account Kit is compatible with any EIP-1193 provider. Many of the most popular signers can be configured in minutes through our integration signer guides. If you want to use another Signer, you can integrate any other Signer by wrapping it in an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) provider or using [`SmartAccountSigner`](/smart-accounts/signers/guides/custom-signer#implementing-smartaccountsigner) to adapt non-standard Signer. diff --git a/site/smart-accounts/signers/guides/dfns.md b/site/smart-accounts/signers/guides/dfns.md new file mode 100644 index 0000000000..a376cfe738 --- /dev/null +++ b/site/smart-accounts/signers/guides/dfns.md @@ -0,0 +1,79 @@ +--- +outline: deep +head: + - - meta + - property: og:title + content: Dfns + - - meta + - name: description + content: Guide for using Dfns as a Signer + - - meta + - property: og:description + content: Guide for using Dfns as a Signer +--- + +# Dfns Integration Guide + +[Dfns](https://www.dfns.co) is an MPC/TSS Wallet-as-a-Service API/SDK provider. Dfns aims to optimize the balance of security and UX by deploying key shares into a decentralized network on the backend while enabling wallet access via biometric open standards on the frontend like Webauthn. Reach out [here](https://www.dfns.co/learn-more) to set up a sandbox environment to get started. + +Dfns seamlessly integrates with Account Abstraction by signing `UserOperation`s. See the examples below for initializing a DFNS signer and creating a provider with that signer. You can follow [this](https://accountkit.alchemy.com/tutorials/sponsoring-gas/sponsoring-gas.html) guide to send and sponsor `UserOperation`s with the provider created. + +Dfns created a full example of a gas-less transaction via a paymaster [in our SDK](https://github.com/dfnsext/typescript-sdk/blob/m/examples/viem/alchemy-aa-gasless/README.md), adapted from our [gas sponsorship example](https://accountkit.alchemy.com/guides/sponsoring-gas.html). + +## Install Dfns SDK + +::: code-group + +```bash [npm] +npm i @dfns/lib-viem @dfns/sdk @dfns/sdk-keysigner +``` + +```bash [yarn] +yarn add @dfns/lib-viem @dfns/sdk @dfns/sdk-keysigner +``` + +::: + +### Create a SmartAccountSigner + +Setup the Dfns Web3 Provider and wrap it in an `AlchemyProvider`. + +<<< @/snippets/dfns.ts + +### Use it with Light Account + +::: code-group + +```ts [example.ts] +import { AlchemyProvider } from "@alchemy/aa-alchemy"; +import { + LightSmartContractAccount, + getDefaultLightAccountFactoryAddress, +} from "@alchemy/aa-accounts"; +import { encodeFunctionData, parseAbi } from "viem"; +import { sepolia } from "viem/chains"; +import { createDfnsSigner } from "./dfns"; + +// Remember to replace "ALCHEMY_API_KEY" with your own Alchemy API key, get one here: https://dashboard.alchemy.com/ +const ALCHEMY_API_KEY = "API_KEY"; +const chain = sepolia; + +const createAlchemyProvider = async (): Promise => { + return new AlchemyProvider({ + apiKey: ALCHEMY_API_KEY, + chain, + }).connect( + (rpcClient) => + new LightSmartContractAccount({ + chain, + owner: await createDfnsSigner(), + factoryAddress: getDefaultLightAccountFactoryAddress(chain), + rpcClient, + }) + ); +}; +``` + +<<< @/snippets/dfns.ts + +::: diff --git a/site/snippets/dfns.ts b/site/snippets/dfns.ts new file mode 100644 index 0000000000..fe6c6e7d39 --- /dev/null +++ b/site/snippets/dfns.ts @@ -0,0 +1,42 @@ +import { LocalAccountSigner, type SmartAccountSigner } from "@alchemy/aa-core"; +import { DfnsWallet } from "@dfns/lib-viem"; +import { DfnsApiClient } from "@dfns/sdk"; +import { AsymmetricKeySigner } from "@dfns/sdk-keysigner"; +import { LocalAccount, toAccount } from "viem/accounts"; + +// See the Dfns example https://github.com/dfnsext/typescript-sdk/blob/m/examples/viem/alchemy-aa-gasless/README.md for details on populating the environment variables. +const DFNS_PRIVATE_KEY = null; +const DFNS_CRED_ID = null; +const DFNS_APP_ORIGIN = null; +const DFNS_APP_ID = null; +const DFNS_AUTH_TOKEN = null; +const DFNS_API_URL = null; +const SEPOLIA_WALLET_ID = null; + +const initDfnsWallet = (walletId: string) => { + const signer = new AsymmetricKeySigner({ + privateKey: DFNS_PRIVATE_KEY!, + credId: DFNS_CRED_ID!, + appOrigin: DFNS_APP_ORIGIN!, + }); + + const dfnsClient = new DfnsApiClient({ + appId: DFNS_APP_ID!, + authToken: DFNS_AUTH_TOKEN!, + baseUrl: DFNS_API_URL!, + signer, + }); + + return DfnsWallet.init({ + walletId, + dfnsClient, + maxRetries: 10, + }); +}; + +export const createDfnsSigner = async (): Promise => { + const sepoliaWallet = await initDfnsWallet(SEPOLIA_WALLET_ID!); + const account = toAccount(sepoliaWallet) as LocalAccount; + const dfnsSigner = new LocalAccountSigner(account as any); + return dfnsSigner; +};