token-gate-web3
v1.0.19
Published
Generic token gate hooks for a nft collection and farcaster
Downloads
26
Readme
React hooks for token gating content via a NFT collection or Farcaster. Requires a Alchemy API key for NFT gating, and a Application bearer token for authenticating a farcaster user. In addition, an existing SIWE implementation is needed.
I recommend using Wagmi or Privy to get an address.
Installation
npm:
npm install token-gate-web3
yarn:
yarn add token-gate-web3
Example
import logo from './logo.svg';
import './App.css';
import{useNFTAuth,useFarcasterAuth } from 'token-gate-web3/lib/esm'
function App() {
const [holder,error] = useNFTAuth({alchemyApiKey:'your-key',wallet: 'user-wallet', contractAddress: 'contract-address'})
const [FCToken,FCError] = useFarcasterAuth({wallet: 'wallet-address', bearerToken:"bearer-token"})
return (
<div className="App">
{holder ? <p>You are a holder</p> :<p>you are not a holder</p>}
{FCToken ? <p>You are a Farcaster user</p> :<p>you are not a farcaster User</p>}
{FCError && <p>Farcaster Error:{FCError.message}</p>}
{error && <p>NFT Error:{error.message}</p>}
</div>
);
}
export default App;
Contributing
For fixes or contributions, please open a issue.
License
This project is licensed under the terms of the MIT license.