🧑‍💻 Initialize

When creating a Face object, you need an API Key and blockchain network parameters that you intend to use.

import { Face } from '@haechi-labs/face-react-native-sdk';
import { Network } from '@haechi-labs/face-types';

const face = new Face({
  network: Network.GOERLI, 
  apiKey: 'YOUR_DAPP_API_KEY',
  scheme: 'CUSTOM_SCHEME'
});

🚧

Face objects cannot be duplicated. For an object that was created, we recommend you manage and use it as a global variable or global state.

👍

For integrating in React environment

For managing Face object as a global variable/state, you might use the Singleton pattern. If you don't need to change the blockchain network, the Singleton pattern is enough. But, if you're developing an application in React Native and need to change blockchain network, you can manage Face object as a global variable/state using a state management library like Recoil or Redux.

You can find an example code using Recoil in here.

  1. Recoil makes you to be able to manage a global state via Atom.
  2. Define and instantiate an atom for managing Face object as global state. (Example)
    • When using the Recoil, it might be occurred an immutable error for changing of the value in Face object. So, you should set dangerouslyAllowMutability to true value when you create an Atom.
  3. Initialize Face object and set it to recoil state. (Example)
  4. When you want to use Face object in other place, get it using recoil value. (Example)

If you want to use chainId, not Network parameter, you can use it.

import { Face, Network } from '@haechi-labs/face-sdk';

const face = new Face({  
  network: 5, // Ethereum Goerli testnet's chain id is 5  
  apiKey: 'YOUR_DAPP_API_KEY'  
});

Network Parameter

Face Wallet supports the following blockchain networks.

BlockchainMainnet ParameterTestnet Parameter
EthereumNetwork.ETHEREUMNetwork.GOELRI
PolygonNetwork.POLYGONNetwork.MUMBAI
BNB Smart ChainNetwork.BNB_SMART_CHAINNetwork.BNB_SMART_CHAIN_TESTNET
KlaytnNetwork.KLAYTNNetwork.BAOBAB
BORANetwork.BORANetwork.BORA_TESTNET

API Key

You need an API Key to use Face Wallet SDK. You can have an API Key issued in Face Wallet Dashboard.