@@ -108,7 +108,8 @@ import {
108108 toMetaMaskSmartAccount ,
109109} from " @metamask/delegation-toolkit" ;
110110
111- const owner = walletClient .account .address ;
111+ const addresses = await walletClient .getAddresses ();
112+ const owner = addresses [0 ];
112113
113114const smartAccount = await toMetaMaskSmartAccount ({
114115 client: publicClient ,
@@ -161,23 +162,37 @@ export const walletClient = createWalletClient({
161162This example creates a [ Viem WebAuthn Account] ( https://viem.sh/account-abstraction/accounts/webauthn ) as the signatory,
162163using Viem's ` toWebAuthnAccount ` function.
163164
165+ :::info Installation required
166+
167+ To work with WebAuthn, we’ll be using the [ Ox] ( https://oxlib.sh/ ) SDK. Please ensure that the SDK is installed.
168+
169+ :::
170+
164171<Tabs >
165172<TabItem value =" example.ts " >
166173
167174``` typescript
168175import { publicClient } from " ./client.ts"
169- import { signatory } from " ./signatory.ts" ;
176+ import { webAuthnAccount , credential } from " ./signatory.ts" ;
170177import {
171178 Implementation ,
172179 toMetaMaskSmartAccount ,
173180} 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 );
174189
175190const smartAccount = await toMetaMaskSmartAccount ({
176191 client: publicClient ,
177192 implementation: Implementation .Hybrid ,
178- deployParams: [owner , p256KeyIds , p256XValues , p256YValues ],
193+ deployParams: [owner , [ credential . id ], [ publicKey . x ], [ publicKey . y ] ],
179194 deploySalt: " 0x" ,
180- signatory ,
195+ signatory: { webAuthnAccount , keyId: toHex ( credential . id ) } ,
181196});
182197```
183198
@@ -201,15 +216,16 @@ export const publicClient = createPublicClient({
201216<TabItem value =" signatory.ts " >
202217
203218``` typescript
204- import { createCredential , parsePublicKey } from " webauthn-p256" ;
205- import { toWebAuthnAccount } from " viem/account-abstraction" ;
206- import { toHex } from " viem" ;
207-
208- const credential = await createCredential ({ name: " Your Delegator Passkey" });
209- const webAuthnAccount = toWebAuthnAccount ({ credential });
210- const keyId = toHex (" my-key-id" );
219+ import {
220+ createWebAuthnCredential ,
221+ toWebAuthnAccount ,
222+ } from " viem/account-abstraction" ;
211223
212- const signatory = { webAuthnAccount , keyId };
224+ export const credential = await createWebAuthnCredential ({
225+ name: " MetaMask Smart Account" ,
226+ });
227+
228+ export const webAuthnAccount = toWebAuthnAccount ({ credential });
213229```
214230
215231</TabItem >
0 commit comments