🧑💻 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 manageFace
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.
- Recoil makes you to be able to manage a global state via
Atom
.- 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
totrue
value when you create an Atom.- Initialize
Face
object and set it to recoil state. (Example)- 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.
Blockchain | Mainnet Parameter | Testnet Parameter |
---|---|---|
Ethereum | Network.ETHEREUM | Network.GOELRI |
Polygon | Network.POLYGON | Network.MUMBAI |
BNB Smart Chain | Network.BNB_SMART_CHAIN | Network.BNB_SMART_CHAIN_TESTNET |
Klaytn | Network.KLAYTN | Network.BAOBAB |
BORA | Network.BORA | Network.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.
Updated 12 months ago