BA
Better Authโ€ข5d ago
4ge

better-auth passkeys + coinbase smart wallet? question about compatibility...

Hi everyone! ๐Ÿ‘‹ I was stoked to see the recent tweet about the new Coinbase x402 plugin โ€“ excited for this direction for better-auth, looking forward to more web3 stuff (like SIWE?) I was looking into how to integrate better-auth passkeys with a smart wallet system, specifically aiming for something like the Coinbase Smart Wallet (or similar stuff like accountkit/pimlico -- they all use viem or Oxlib under the hood i think). The goal is to have a smart wallet counterfactually created for a user right when they register a passkey through better-auth in my Next app I've been digging into a couple of resources: - viem's toCoinbaseSmartAccount: https://viem.sh/account-abstraction/accounts/smart/toCoinbaseSmartAccount - Oxlib's WebAuthn guide: https://oxlib.sh/guides/webauthn (which viem uses under the hood for some parts) My main question is around the WebAuthn credential handling. For example, viem has methods like createWebAuthnCredential and toWebAuthnAccount. I know both better-auth's passkey registration and these viem functions probably ultimately use navigator.credential.create under the hood, but I'm wondering if the passkey credentials/public keys generated and stored by better-auth can be directly and seamlessly used with these viem (or oxlib) functions to init/control a smart account. anyone exploring this or have insights on compatibility here? Any thoughts, experiences, or pointers from folks who've ventured into this territory would be massively appreciated! Thanks so much! Sorry if this is a totally noob question!
8 Replies
Byron
Byronโ€ข5d ago
@4ge Hey dude, you might want to hold off while we wrap this up: https://github.com/better-auth/better-auth/pull/2579 Passkey support is quite niche (despite it being great UX) - why not just use Coinbase Smart Wallet outta interest?
GitHub
feat: SIWE plugin by rokitgg ยท Pull Request #2579 ยท better-auth/b...
Aims to close #41 Tried my best to implement SIWE within the boundaries of better-auth, and seems like this draft may be a good starting point for it! Although I do feel like a bit of discussion is...
4ge
4geOPโ€ข5d ago
that looks ๐Ÿ”ฅ yeah that's what I was wondering -- to have rest of our auth system managed by better-auth and to use passkeys created by coinbase smart wallet just one question: if I register a passkey using other libraries (coinbase/alchemy accountkit) and store the credential in better-auth's auth.passkey table (conformant to the schema) will it play nice with rest of the auth system -- i.e. can I use authClient.signIn.passkey() with it?
Byron
Byronโ€ข5d ago
Oh I see what you mean, I am not entirely sure but I'll be integrating the same thing when this is merged so I'll have to figure it out ๐Ÿ˜„ Are you using onchainkit?
4ge
4geOPโ€ข5d ago
I've been weighing my options between accountkit/onchainkit and other solutions but yeah I onchainkit is what we'll likely go with I was gonna take a stab at hacking with viem and better-auth library code myself to see it works. I think it should -- just want to make sure the types P256Credential (from Ox) and PublicKeyCredential (from WebAuthn) are compatible I'll check out your code ๐Ÿซก
Byron
Byronโ€ข5d ago
Also a word of advice, smart accounts are great for now but ERC-7702 will likely supersede them. I was also planning on doing the same. Literally adding onchainkit right now let's stay in touch!
4ge
4geOPโ€ข5d ago
IIRC smart accounts are still the way to go if you want to generate a wallet inside the app hiding the complexity from the user, yeah? not super up to date on 7702, will go through it Yes, thanks a lot and do keep me updated!
Byron
Byronโ€ข5d ago
What are you using as the signer account of the smart wallet though? This usually has to be an EOA anyway. If I'm understanding correctly you are creating wallets programmatically after user sign in / up
4ge
4geOPโ€ข5d ago
creating wallets programmatically after user sign in / up
yep. the idea is to almost hide the crypto wallet altogether from mainstream users in the initial stages of our project re: signer i'm trying to have transactions/userops signed via passkey using RIP-7212 (https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md#motivation)

Did you find this page helpful?