Particle Auth Core Modal
Auth Core provides MPC (Multi-Party Computation)-based threshold signatures.
Modal is implemented based on React, provides a rich set of hook functions and custom components.
Installation
Install Auth Core and its peer dependencies.
npm install @particle-network/authkit
# or
yarn add @particle-network/authkit
Configure
Init Auth Core with Particle project config, you can get the config from Particle Dashboard.
The modal support custom style, refer to Customize.
Wrap your application with AuthCoreContextProvider
.
import { AuthCoreContextProvider } from '@particle-network/authkit';
const App = () => {
return (
<AuthCoreContextProvider
options={{
projectId: 'xxxx',
clientKey: 'xxxx',
appId: 'xxxx',
}}
>
<YourApp />
</AuthCoreContextProvider>
);
};
Connect
Custom you own connect button and call connect
function to connect Auth Core.
import { useConnect } from '@particle-network/authkit';
const { connect, disconnect, connectionStatus, requestConnectCaptcha } = useConnect();
const userInfo = await connect({
email: 'xxx@xx.com',
code: 'xxxxxx',
});
const userInfo = await connect({
phone: '+8618888888888',
code: 'xxxxxx',
});
const userInfo = await connect({
socialType: 'google',
prompt: 'select_account',
});
const userInfo = await connect({
jwt: 'xxxxxxxxxx',
});
await disconnect();
EVM Wallet
EVM Wallet will be created when connect with EVM chains.
import { useEthereum } from '@particle-network/authkit';
const { provider, address, chainId, chainInfo, switchChain, signMessage, signTypedData, sendTransaction, enable } =
useEthereum();
const txHash = await sendTransaction(txData);
const signature = await signMessage(message);
Solana Wallet
import { useSolana } from '@particle-network/authkit';
const {
address,
chainId,
chainInfo,
switchChain,
signMessage,
signTransaction,
signAllTransactions,
signAndSendTransaction,
enable,
} = useSolana();
const txHash = await signAndSendTransaction(txData);
const signature = await signMessage(message);
Learn More