@@ -48,7 +48,7 @@ This example creates a signatory from a private key using Viem's [`privateKeyToA
4848
4949``` typescript
5050import { publicClient } from " ./client.ts"
51- import { signatory } from " ./signatory.ts" ;
51+ import { account } from " ./signatory.ts" ;
5252import {
5353 Implementation ,
5454 toMetaMaskSmartAccount ,
@@ -57,9 +57,9 @@ import {
5757const smartAccount = await toMetaMaskSmartAccount ({
5858 client: publicClient ,
5959 implementation: Implementation .Hybrid ,
60- deployParams: [owner , p256KeyIds , p256XValues , p256YValues ],
60+ deployParams: [account . address , [], [], [] ],
6161 deploySalt: " 0x" ,
62- signatory ,
62+ signatory: { account } ,
6363});
6464```
6565
@@ -86,9 +86,7 @@ export const publicClient = createPublicClient({
8686import { privateKeyToAccount , generatePrivateKey } from " viem/accounts" ;
8787
8888const privateKey = generatePrivateKey ();
89- const account = privateKeyToAccount (privateKey );
90-
91- export const signatory = { account };
89+ export const account = privateKeyToAccount (privateKey );
9290```
9391
9492</TabItem >
@@ -104,18 +102,21 @@ using Viem's `createWalletClient` function.
104102
105103``` typescript
106104import { publicClient } from " ./client.ts"
107- import { signatory } from " ./signatory.ts" ;
105+ import { walletClient } from " ./signatory.ts" ;
108106import {
109107 Implementation ,
110108 toMetaMaskSmartAccount ,
111109} from " @metamask/delegation-toolkit" ;
112110
111+ const addresses = await walletClient .getAddresses ();
112+ const owner = addresses [0 ];
113+
113114const smartAccount = await toMetaMaskSmartAccount ({
114115 client: publicClient ,
115116 implementation: Implementation .Hybrid ,
116- deployParams: [owner , p256KeyIds , p256XValues , p256YValues ],
117+ deployParams: [owner , [], [], [] ],
117118 deploySalt: " 0x" ,
118- signatory ,
119+ signatory: { walletClient } ,
119120});
120121```
121122
@@ -146,13 +147,11 @@ import { http, createWalletClient } from "viem";
146147const privateKey = generatePrivateKey ();
147148const account = privateKeyToAccount (privateKey );
148149
149- const walletClient = createWalletClient ({
150+ export const walletClient = createWalletClient ({
150151 account ,
151152 chain ,
152153 transport: http ()
153154})
154-
155- export const signatory = { walletClient };
156155```
157156
158157</TabItem >
@@ -163,23 +162,37 @@ export const signatory = { walletClient };
163162This example creates a [ Viem WebAuthn Account] ( https://viem.sh/account-abstraction/accounts/webauthn ) as the signatory,
164163using Viem's ` toWebAuthnAccount ` function.
165164
165+ :::info Installation required
166+
167+ To work with WebAuthn, install the [ Ox SDK] ( https://oxlib.sh/ ) .
168+
169+ :::
170+
166171<Tabs >
167172<TabItem value =" example.ts " >
168173
169174``` typescript
170175import { publicClient } from " ./client.ts"
171- import { signatory } from " ./signatory.ts" ;
176+ import { webAuthnAccount , credential } from " ./signatory.ts" ;
172177import {
173178 Implementation ,
174179 toMetaMaskSmartAccount ,
175180} from " @metamask/delegation-toolkit" ;
181+ import { Address , PublicKey } from " ox" ;
182+ import { toHex } from " viem" ;
183+
184+ // Deserialize compressed public key
185+ const publicKey = PublicKey .fromHex (credential .publicKey );
186+
187+ // Convert public key to address
188+ const owner = Address .fromPublicKey (publicKey );
176189
177190const smartAccount = await toMetaMaskSmartAccount ({
178191 client: publicClient ,
179192 implementation: Implementation .Hybrid ,
180- deployParams: [owner , p256KeyIds , p256XValues , p256YValues ],
193+ deployParams: [owner , [ credential . id ], [ publicKey . x ], [ publicKey . y ] ],
181194 deploySalt: " 0x" ,
182- signatory ,
195+ signatory: { webAuthnAccount , keyId: toHex ( credential . id ) } ,
183196});
184197```
185198
@@ -203,15 +216,16 @@ export const publicClient = createPublicClient({
203216<TabItem value =" signatory.ts " >
204217
205218``` typescript
206- import { createCredential , parsePublicKey } from " webauthn-p256" ;
207- import { toWebAuthnAccount } from " viem/account-abstraction" ;
208- import { toHex } from " viem" ;
209-
210- const credential = await createCredential ({ name: " Your Delegator Passkey" });
211- const webAuthnAccount = toWebAuthnAccount ({ credential });
212- const keyId = toHex (" my-key-id" );
219+ import {
220+ createWebAuthnCredential ,
221+ toWebAuthnAccount ,
222+ } from " viem/account-abstraction" ;
213223
214- const signatory = { webAuthnAccount , keyId };
224+ export const credential = await createWebAuthnCredential ({
225+ name: " MetaMask Smart Account" ,
226+ });
227+
228+ export const webAuthnAccount = toWebAuthnAccount ({ credential });
215229```
216230
217231</TabItem >
0 commit comments