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:
State | Description |
---|---|
0 - NONE | The initial state of the SDK. |
1 - UNAUTHENTICATED | Before the user is authenticated. |
2 - EMBEDDED_SIGNER_NOT_CONFIGURED | Before calling embeddedWallet.configure . |
3 - CREATING_ACCOUNT | If no account exists for the current chainID, when it will be created. |
4 - READY | The 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();