Skip to main content

Sign In With Elympics

Elympics Account is the main identity for Players and Developers on Elympcis Protocol. This article describes the Sign In with Elympics process using an EVM Wallet.

note

This process is usually automated and implemented in Elympics SDK and Elympics Web Host, but you can use it for reference and/or implement this process in your game.

Sign in with EVM

The sign in process with EVM consists of the following steps:

  1. Connect Wallet
  2. Fetch the challenge nonce from Elympics
  3. Sign the nonce with eth_signTypedData
  4. Sign the user in with the address, nonce and signature.

Connect Wallet

This process is a classic Web3 Wallet Connection. You can use web3.js, ethers, viem or any other framework. Once you have the connection, you can sign the user into Elympics.

Fetch the nonce challenge

In order for the user to prove, that they're in control of the connected wallet, they need to sign an Elympics-generated challange (nonce). First, fetch the nonce, and later sign the message.

PUT: https://api.elympics.cc/v2/auth/user/ethAddressV2Nonce

Request:

{
"address": "0xabc....123"
}

Response:

{
"nonce": "string"
}

Sign the nonce

Use the signTypeData_v4 flow from EIP-712 to sign the nonce. Here's a sample code in wagmi and typescript:

const message = {
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
],
Login: [
{ name: "player", type: "address" },
{ name: "nonce", type: "string" },
],
},
primaryType: "Login",
message: {
player: address,
nonce: nonce,
},
domain: {
name: "Elympics:Login",
version: "1",
chainId: chainId,
},
};
const signature = await signTypedDataAsync(message);

Sign in to Elympics with the signature

POST: https://api.elympics.cc/v2/auth/user/ethAddressV2Auth

Request:

{
"typedData": "string",
"signature": "string",
}

Response:

{
"jwtToken": "string",
"userId": "string",
"nickname": "nickname",
}

Using the JWT Token you can fetch data about the user in Elympics.