๐Ÿคนโ€โ™‚๏ธIncremental Token Gating

A guide to start incremental token gating anything in minutes.

Requirements

Before continuing make sure you've followed the setup guide

If you are unfamiliar with token gating, we recommend reading one of the other token gating guides first

To understand the use cases for incremental token gating, read the incremental authorization concept page

Incremental Token Gating

You can use Picket to token gate anything. Incremental token gating, also know as incremental authorization, allows you to token gate after the user is logged in. If the user meets the token ownership requirements, we'll automatically handle updating their access token for you. This makes all future checks for the same token ownership lightning fast.

1. Log In the User

import Picket from "@picketapi/picket-js";

const picket = new Picket('YOUR_PUBLISHABLE_KEY_HERE');

const { accessToken,  user } = await picket.login({
  // specify the chain
  chain: "polygon"
});

2. Token Gate Specific Actions or Content

Once the user is logged, you can authorize for specific requirements. This can be used to prevent users from clicking a button or accessing page if they don't have certain tokens.

// after logging in a user
// authorization automatically happens on the same chain the user logged in on
const allowed = picket.isCurrentUserAuthorized({
  requirements: {
    contractAddress: "YOU_CONTRACT_ADDRESS"
  }
});
console.log("is the current user authorized?", allowed);

You successfully logged in a user and token gated content!

Every time a user is successfully authorized for a new requirement, their access token will automatically be updated to reflect it.

Using Access Tokens

Congrats ๐ŸŽ‰ your user is now successfully logged in. After authenticated/authorizing a user, you get an access token. You can use this access token to make secure requests to your backend. Read more in the working with access tokens guide.

Last updated