πWallet Login
A guide to start authenticating wallets in minutes.
Requirements
βοΈStart Here: SetupWallet Authentication
import Picket from "@picketapi/picket-js";
const picket = new Picket('YOUR_PUBLISHABLE_KEY_HERE');
const { accessToken, user } = await picket.login({ chain: "ethereum" });
console.log(user);//Logs the user object for your inspection.import { PicketProvider, usePicket } from "@picketapi/picket-react";
function MyApp({ children }) {
return (
<PicketProvider apiKey="YOUR_PUBLISHABLE_KEY_HERE">
{children}
</PicketProvider>
);
}
// set this to the chain you want to authenticate users for
// if the chain parameters is omitted, it will default to the ethereum mainnet
const chain = "ethereum"; // "solana"
function MySecurePage() {
const {
isAuthenticating,
isAuthenticated,
authState,
logout,
login
} = usePicket();
// user is logging in
if (isAuthenticating) return "Loading";
// user is not logged in
if (!isAuthenticated) {
return (
<div>
<p>You are not logged in!</p>
<button onClick={() => login({ chain })}>
Login with Wallet
</button>
</div>
)
}
// user is logged in π
const { user } = authState;
const { walletAddress } = user;
return (
<div>
<p>You are logged in as {walletAddress} </p>
<button onClick={() => logout()}>Logout</button>
</div>
)
}Using Authenticated Wallets for On Chain Interactions
Using Access Tokens
πWorking with Access TokensLast updated