Management API Reference

Server

Pregenerating an embedded signer

You can pregenerate self-custodial smart account associated with a given account, like an email address or social login, without requiring the user to login. You can even send assets to the wallet before the user logs in to your app for the first time. Once the user associated with the account logs in, they will be able to access the pregenerated wallet and any assets sent to them. To pregenerate embedded signers, use one of the supported backend SDKs:

A user can easily claim their pregenerated account simply by logging into your app with one of its linked accounts.

server.ts

_21
// Set your secret key. Remember to switch to your live secret key in production.
_21
// See your keys here: https://dashboard.openfort.xyz/developers/api-keys
_21
const Openfort = require('@openfort/openfort-node').default;
_21
const openfort = new Openfort(YOUR_SECRET_KEY);
_21
_21
const notifications = await openfort.iam.createAuthPlayer(
_21
{
_21
thirdPartyUserId: "user id",
_21
thirdPartyProvider: 'provider name', // Id of the provider of the user
_21
preGenerateEmbeddedAccount: true
_21
chainId: 4337,
_21
metadata: {
_21
name: "Jaume"
_21
}
_21
},
_21
{
_21
shieldAuthProvider: '', // ShieldAuthProvider.OPENFORT or ShieldAuthProvider.CUSTOM
_21
apiKey: '', // Shield publishable key
_21
apiSecret: '', // Shield secret key
_21
encryptionPart: '' // Shield encryption share
_21
})

In the body of the request:

  • Include a thirdPartyUserId array that contains the user's account to claim the wallet.
  • Include a thirdPartyProvider array that contains the provider used: Openfort, custom, supabase, etc.
  • Include a preGenerateEmbeddedAccount boolean with the value true.

A successful response will include the new user object along with their DID and embedded signer address, like below:

json

_13
{
_13
"id": "pla_ff54b031-a878-4ca2-9cf5-ae190f921e9b",
_13
"object": "player",
_13
"createdAt": 1691658234,
_13
"linkedAccounts": [
_13
{
_13
"provider": "email",
_13
"email": "jaume@openfort.xyz",
_13
"disabled": false,
_13
"updatedAt": 1691658234
_13
}
_13
]
_13
}