Integrate with Turnkey

The steps given below contain instructions on how to integrate Enclave's SDK with an application that uses Turnkey's React SDK

Demo Repository

Step 1: Install Enclave Money

Step 2: Initialize Enclave Client

Step 3: Create Account with Turnkey as Signing Key

In the snippet given below we:

  • Import 3rd party dependencies

  • Retrieve the active Turnkey signing key address

  • Create an Enclave account on all supported networks using the Turnkey signing key

The user can transfer USDC to the account address returned from the createSmartAccount response and start transacting on any supported chain with their USDC deposits.

Step 3: Build User Operation

In the example below we build a user operation to transfer USDC. This requires the user to have an account (created in Step 2) and the user must transfer USDC to their account. The user can deposit USDC on any supported chain and spend their funds on any chain.

Step 4: Sign User Operation

In the snippet below we create a Turnkey ethers signer and sign the user operation hash (buildTxn.messageToSign) retriveed in Step 3.

Step 5: Submit User Operation

In the code snippet given below we use the enclave SDK to submit the signed user operation using builtTxn from Step 3 and the signature from Step 4

Conclusion

Congratulations! You have now added chain abstraction capabilities to your application using Turnkey as the signing key. This effectively allows your users to spend their unified USDC balance across chains for executing any on-chain action using their preferred authentication, authorization and signing methods provided by Turnkey (ex. Email, Google, Passkey, etc).

Last updated