Initialize
When creating a Kit
object, you need an initialized Face
object and a few options.
import { Face } from '@haechi-labs/face-sdk';
import { Kit, getMetaMask, getWalletConnect } from '@haechi-labs/face-kit';
import { LoginProvider } from '@haechi-labs/face-types';
import { klaytn } from "@wagmi/chains"; // or you can use viem/chains like `import { klaytn } from "viem/chains"`;
// Put the initialized face instance to Kit
const face = new Face(/* ... */);
const kit = new Kit(face, {
providers: [
/* You can set social providers you want use */
LoginProvider.Google,
LoginProvider.Apple,
LoginProvider.Discord
],
externalWalletOptions: {
wallets: [
getMetaMask(),
getWalletConnect({
options: { projectId: wcProjectId },
chains: [
/*
you must config chains to use in the WalletConnect.
Otherwise, it will be set to default lists(BSC, BSC Testnet, Ethereum, Sepolia, Polygon, Mumbai).
You can choose chains to use in "@wagmi/chains" or "viem/chains".
*/
klaytn,
/*
Also, you can config your custom chains that is not in "@wagmi/chains" or "viem/chains", as shown below.
*/
{
id: 20197,
name: "Sandverse",
network: "Oasys Sandverse",
rpcUrls: {
default: { http: ["https://rpc.sandverse.oasys.games"]},
public: { http: ["https://rpc.sandverse.oasys.games"]}
},
},
]
})
],
expanded: false,
},
});
Options
KitConfig
Option | Description | Default value |
---|---|---|
providers | Use it as an array of Social Login Providers. If you put it in an empty array, it will only show the external wallets without any social login. | [LoginProvider.Google ,LoginProvider.Apple ,LoginProvider.Discord ,LoginProvider.Facebook ,LoginProvider.Kakao ] |
externalWalletOptions | Option for external wallets, passing an array of external wallets to use. | No default (required) |
externalWalletOptions
Option | Description | Default value |
---|---|---|
wallets | An array of external wallet objects to connect to. | No default (required) |
expanded | Option for how external wallets are displayed. If true , external wallets are shown at the same depth as social login instead of the [View more] button. If false , external wallets can be selected via the [View more] button. By hiding the external wallet with the [View more] button once, users who are not familiar with wallet can connect the wallet without fear. | false |
chains
Option | Description |
---|---|
id | The chain ID of the blockchain network to set up. |
name | The name of the blockchain to set up. |
network | The name of the blockchain network to set up. |
rpcUrls | RPC Url of the blockchain network to set up. |
If you put the
providers
option as an empty array ([]) and don't setwallets
, an error occurs. Either value must be set.
Updated 10 months ago