Using the Openfort SDKs
There are two steps to configure Openfort's embedded wallets in your application:
- Configure the embedded signer configuration.
- Wait for the embedded signer to be ready.
Embedded signer configuration#
The Openfort SDKs provide a way to configure a non-custodial embedded signer that can be used to sign transactions and interact with the blockchain.
The configureEmbeddedSigner
is the method responsible for setting up and creating the non-custodial wallet.
The configureEmbeddedSigner
will include a chainID
parameter, which is the identifier of the blockchain network you want to interact with and create an embedded signer there. You can read the list of supported chains here.
Let's go over the rest of the shieldAuth
parameters of the configureEmbeddedSigner
method:
Parameter | Description |
---|---|
auth | Defines how the token parameter is going to be verified. Can be either openfort or custom, defining if the token is going to be verified by Openfort or by another backend. |
token | The access_token or id_token that will be used to verify that the user is logged in in your application. |
Automatic embedded signer creation: to offer a frictionless onboarding, you can enlable automatic embedded signer creation. Learn more about it how to enable automatic recovery.
Waiting for ready#
When calling configureEmbeddedSigner
, 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_SIGINER_NOT_CONFIGURED | Before calling the configureEmbeddedSigner . |
3 - CREATING_ACCOUNT | If no account exists for the current chainID, when it will be created. |
4 - READY | The embedded signer is ready to be used |
As a consequence, it's important to wait until the embeddedState
has finished initializing before you use the embedded signer, to ensure that the state you consume is accurate and not stale.
To determine whether the Openfort SDK has initialized the embedded signer, you can call the method getEmbeddedState
and check if the state is READY
: