Home

Authentication

External Wallet Login

Learn how to connect the external wallets to onboard users.

Connect wallet via the Sign in With Ethereum (SIWE) standard. Catered to users who prefer to authenticate using their external wallets, supporting various types such as injected, browser-based, and mobile wallets. Openfort’s integration facilitates a secure and direct authentication process using these wallets.

First create a challenge for the user to sign with their wallet by constructing a SIWE challenge using the nonce returned from the server:


_11
import Openfort from "@openfort/openfort-js";
_11
const openfort = new Openfort({
_11
baseConfiguration: {
_11
publishableKey: OPENFORT_PUBLISHABLE_KEY
_11
}
_11
});
_11
const address = 'EXTERNAL_WALLET_ADDRESS';
_11
_11
async function initSIWE() {
_11
await openfort.initSIWE({address});
_11
}

Then, verify the SIWE signature to authenticate the user:

  • walletClientType: e.g. coinbaseWallet, metamask, etc.
  • connectorType: wallet_connect_v2, injected, coinbase_wallet, etc.

_16
import Openfort from "@openfort/openfort-js";
_16
const openfort = new Openfort({
_16
baseConfiguration: {
_16
publishableKey: OPENFORT_PUBLISHABLE_KEY
_16
}
_16
});
_16
const address = 'EXTERNAL_WALLET_ADDRESS';
_16
_16
async function authSIWE(signature, message, walletClientType, connectorType) {
_16
await openfort.authenticateWithSIWE({
_16
signature: signature,
_16
message: SIWEMessage,
_16
connectorType: connector?.type,
_16
walletClientType: connector?.name,
_16
});
_16
}

And you’re done! The user is now authenticated and can access your application.

Uppon successful authentication, the SDK will return a token that can be used to authenticate the user in your application.

response.json

_16
{
_16
"player": {
_16
"id": "pla_cc9ed2b7-c5f5-4c43-8dca-c4b104ba1762",
_16
"object": "player",
_16
"createdAt": 1710976453,
_16
"linkedAccounts": [
_16
{
_16
"provider": "wallet",
_16
"address": "0x1234567890abcdef",
_16
"disabled": false,
_16
}
_16
]
_16
},
_16
"token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImNmODNlMTM1N2VlZmI4YmRmMTU0Mjg1MGQ2NmQ4MDA3ZDYyMGU0MDUwYjU3MTVkYzgzZjRhOTIxZDM2Y2U5Y2U0N2QwZDEzYzVkODV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