Skip to content

Using the JS SDKs

There are two steps to configure Openfort's embedded wallets in your application:

  • Configure the embedded wallet configuration.
  • Wait for the signer to be ready.

Waiting for ready

When calling embeddedWallet.configure, embeddedWallet.create or embeddedWallet.recover, the SDK will go through a series of states before it is ready to be used. These states are represented by the enum:

StateDescription
0 - NONEThe initial state of the SDK.
1 - UNAUTHENTICATEDBefore the user is authenticated.
2 - EMBEDDED_SIGNER_NOT_CONFIGUREDBefore calling embeddedWallet.configure.
3 - CREATING_ACCOUNTIf no account exists for the current chainID, when it will be created.
4 - READYThe embedded wallet is ready to be used

As a consequence, it's important to wait until the embeddedState has finished initializing before you use the embedded wallet, to ensure that the state you consume is accurate and not stale.

To determine whether the Openfort SDK has initialized the embedded wallet, you can call the method embeddedWallet.getEmbeddedState and check if the state is READY:

main.ts
import openfort from "./openfortConfig";
 
const state = await openfort.embeddedWallet.getEmbeddedState();