Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: dfns new signer #313

Merged
merged 21 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
35bddae
docs: new signer dfns
avarobinson Dec 6, 2023
17d5e45
fix: prettier on dfns doc
avarobinson Dec 11, 2023
7cf8a10
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
6aa7e9f
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
36f1968
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
2ee47b1
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
6eb3318
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
e38c6ce
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
6f17e0d
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
137c430
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
92dac9b
docs: small text fix
avarobinson Dec 11, 2023
e6364d0
docs: prettier run
avarobinson Dec 11, 2023
64719a9
fix: link typo
avarobinson Dec 11, 2023
45fb579
docs: Update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
83d03b2
docs: update site/snippets/dfns.ts
avarobinson Dec 11, 2023
2b753c4
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
46c2b59
docs: update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
d166c08
docs: Update site/smart-accounts/signers/guides/dfns.md
avarobinson Dec 11, 2023
ba4f80e
docs: removing manual list of signer choices
avarobinson Dec 11, 2023
910193a
Update site/smart-accounts/signers/choosing-a-signer.md
avasisht23 Dec 11, 2023
8d91364
docs: update
avasisht23 Dec 11, 2023
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
1 change: 1 addition & 0 deletions site/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
],
Expand Down
2 changes: 1 addition & 1 deletion site/overview/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
4 changes: 2 additions & 2 deletions site/overview/why-account-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 bespoke 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.
avasisht23 marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
13 changes: 1 addition & 12 deletions site/smart-accounts/signers/choosing-a-signer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 below.
avasisht23 marked this conversation as resolved.
Show resolved Hide resolved

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.

Expand Down
79 changes: 79 additions & 0 deletions site/smart-accounts/signers/guides/dfns.md
Original file line number Diff line number Diff line change
@@ -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<AlchemyProvider> => {
return new AlchemyProvider({
apiKey: ALCHEMY_API_KEY,
chain,
}).connect(
(rpcClient) =>
new LightSmartContractAccount({
chain,
owner: await createDfnsSigner(),
factoryAddress: getDefaultLightAccountFactoryAddress(chain),
rpcClient,
})
);
};
```

<<< @/snippets/dfns.ts

:::
42 changes: 42 additions & 0 deletions site/snippets/dfns.ts
Original file line number Diff line number Diff line change
@@ -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<SmartAccountSigner> => {
const sepoliaWallet = await initDfnsWallet(SEPOLIA_WALLET_ID!);
const account = toAccount(sepoliaWallet) as LocalAccount;
const dfnsSigner = new LocalAccountSigner(account as any);
return dfnsSigner;
};
Loading