βRestrict Access to Specific Wallets
A guide to restricting access based on a list of allowed wallet addresses
Requirements
βοΈStart Here: SetupRestrict Access to Specific Wallets
Login User w/ a Allowed Wallet List
import Picket from "@picketapi/picket-js";
const picket = new Picket('YOUR_PUBLISHABLE_KEY_HERE');
// Restrict access to a set of predefined wallets
const requirements = {
allowedWallets: ["0xYOUR", "0xWALLET", "0xADDRESSES","0xHERE"]
}
const { accessToken, user } = await picket.login(requirements);
console.log(user);import { PicketProvider, usePicket } from "@picketapi/picket-react";
function MyApp({ children }) {
return (
<PicketProvider apiKey="YOUR_PUBLISHABLE_KEY_HERE">
{children}
</PicketProvider>
);
}
// Restrict access to a set of predefined wallets
const requirements = {
allowedWallets: ["0xYOUR", "0xWALLET", "0xADDRESSES","0xHERE"]
}
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(requirements)}>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>
)
}Allowed Wallets and Token Ownership Requirements
Using Access Tokens
πWorking with Access TokensLast updated