Registration Flow

Dexilon is a non custodial solution using the fact that we got Ethereum wallet, which can create a signature to prove something. Using such proof Dexilon can "register" user and "authorize" user

  • User creates a ECDSA signature with Ethereum wallet

  • In signature body a cosmos address is given

  • Dexilon chain creates a proven mapping of address ETH -> Dexilon, Dexilon -> ETH

  • User can control his funds directly with Metamask wallet (without signing the cosmos transactions by Ethereum Wallet)

Such address mapping creation can be understood as creating a trusted connection between a Dexilon and an Ethereum Addresses, because to create it you have to control both of the wallets.

Temporary and primary addresses: granter and grantee wallets

There are two type cosmos addresses in Dexilon Chain:

  • granter - who's fund are gonna be controlled by the grantee address

  • grantee - who now can control granter's funds and gets the permissions to do it for some time.

Using the ECDSA signature we can give control to the user's funds to a temporary user's Dexilon wallet. This wallet has to be generated every single time, when user connects his wallet to the platform After that the wallet can be used during the browser tab is alive. Since the tab dies, the private key of this temporary wallet dies too. No local storage or any other similar thing. The private key is stored only in the runtime of JS App

How to create a new account on Dexilon

Step 1: SDK initialization

First of all you need to configure the SDK properly and generate a new wallet before creating a client instance.

const config: Config = {
  blockchainApiUrl: 'https://proxy.staging.dexilon.io',
  chainId: 'dexilon-staging',
  bondDenom: 'dxln',
};
const api = new BlockchainAPI(config);
const granterWallet = await getRandomCosmosAddress(); // Generating a new address
const granterClient = new DexilonClient(granterWallet.wallet, api, config);
await granterClient.init();

Step 2: Make a request to the faucet

Step 3: Create an instance of web3 Ethereum Wallet

To create an ECDSA signature with your Ethereum Wallet, you need to create an instance of it in the code:

Step 4: Create a signature

Here we declare signing message structure and putting the main wallet addressΒ into it. After that we signing it with etherWallet and receiving the signature instance.

Step 5: Create an address mapping - aka Registration

  • creation of an ECDSA signature with your Ethereum Wallet is shown on the Step 4. Now we have a signed (proven) fact, that this this Ethereum Wallet trusts this particular Dexilon address. So now we have proof of Ethereum Address -> Dexilon Address

  • Next what we got to do is to send a Dexilon's GrantPermissions transaction with you primary wallet. As you can see we providing two signatures (one in raw way, another one in Dexilon tx structure), what is enough to prove the fact of controlling both of them)

Some helpful examples

Here we do few important things:

  • Creating two new addresses: granter wallet can be understood as you primary wallet and grantee wallet is a "session" wallet.

  • faucet: Cosmos-SDK is designed such way, that address is not in the state of the blockchain until it has any funds. So even you don't have to pay gas, you still need some tokens on the balance to create a transaction. Thats why we developed a faucet service, which "activates" the address by sending it some very small amount of tokens

  • Here we create two clients. Just to show, that at first step we gonna create an Address mapping. After that we gonna to use grantee client as a session client. So this is just for an example. Don't use two of them at the same time in you code.

How to sign a message with Web3 Ethereum wallet ?
How to create a wallet instance from mnemonic phrase?

Now you have created an address mapping. Now you can create a session wallet and send transactions with it

Authentication Flow

Last updated