Skip to content

Email Association

Overview

A necessary step before a user can trade his/her assets is to go through the most minimal minimal KYC: use a verified email. Each web3 address needs to be associated to a verified email.

Note

Assets can be created to web3 addresses that have never been associated to any email. It is only when those assets engage in trading that email association is required.

This is a necessary step to be able to transact in FIAT, required by any 3rd party payments provider, as well as to offer trading services in many countries. It protects clients and their users.

A web3 address can only be associated, at any given time, to one email. However, multiple web3 addresses can be associated to the same email.

Code

Email registration needs to be done only once per user. In this process:

  1. The Universe owner is responsible for verifying the user's email by whatever method is preferred.
  2. The Universe owner relays the user's signature accepting to link the email to a web3 address.

The first step is business as usual.

The second step is easily done by following this example. By executing the mutation described below, the Universe Owner states that the user's email has been verified, and that the user wishes to link a web3 address to such email. The backend checks that the mutation comes from the Universe Owners by verifying the b2b token, and the user's intention by verifying the user's signature.

const { digestLinkAddress, sign } = require('freeverse-marketsigner-js');

// Compute the digest to be signed:
const digest = digestLinkAddress({ email, web3address });

// sign with your favorite method,
// using a user's web3 account instantiated from a privKey in this example:
const signature = sign({ digest, web3account: userWeb3Account });
const signatureWithout0x = signature.substring(2, signature.length);

const graphQLMutation = `
  mutation {
    linkWeb3AddressToEmail(
      input: {
        email: "${email}",
        alias: "My first web3 account ever",
        web3Address: "${userWeb3Address}",
        signature: "${signatureWithout0x}",
        universeName: "The Amazing Game",
        language: "en",
        sendEmail: true
      }
    )
  }`;

Note

This mutation needs the proper universe owner b2b auth token to be included in the headers.

Note

It is important to properly verify emails. For example, notifications will be sent directly to the email associated to a given web3 address.

The parameter sendEmail is optional, with default value true. If the mutation is successful and sendMail is true, the user will receive an email informing that the provided web3Address has been linked to the corresponding email.

universeName and language are also optional. Currently, the email languages supported are English ("en") and Spanish ("es").

If a web3 address has already been linked to an email, the following query will return a bound boolean with value true:

query {
  userById(id: "0xf3Bdc620f7B6824678f27733767F1cDF747C440b") {
    bound
  }
}