FirstBatch
Search…
⌃K

Gates & Permission

Gates are requirements attached to events. These requirements can be:
  • Having a certain set of persona traits
  • Having personhood rank higher than X
  • Owning specified amounts of ERC-20 and ERC-721 tokens
FirstBatch currently supports Ethereum, Polygon and Solana ERC-20 & ERC-721 tokens
To create an event only eligible for users with "Game Development" interest:
Python
Node
from firstbatch import EventTypes, Gate, PersonaMap
event = fb.create_event(name="MyEvent", event_type=EventTypes.INTEREST_GATED)
event.attach_gate(Gate(group_id=PersonaMap["Game Development"]))
fb.add_gate(event)
# Booting event required for newly created events
fb.boot_event(event)
const {FirstbatchClient, EventTypes, Gate, PersonaMap} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function addGate(){
await firstbatch.auth()
const event = await firstbatch.createEvent("MyEvent", EventTypes.INTEREST_GATED)
await event.attachGate(new Gate(PersonaMap["Game Development"]))
await firstbatch.addGate(event)
}
addGate()
Only one group_id can be attached to an event as a gate. To use multiple interests, persona traits or ranks; use custom persona.
To create an event only eligible for users with a personhood rank higher than "rank_3":
Python
Node
from firstbatch import EventTypes, Gate, PersonhoodMap
event = fb.create_event(name="MyEvent", event_type=EventTypes.AIRDROP)
event.attach_gate(Gate(group_id=PersonhoodMap["rank_3"]))
fb.add_gate(event)
# Booting event required for newly created events
fb.boot_event(event)
const {FirstbatchClient, EventTypes, Gate, PersonhoodMap} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function addGate(){
await firstbatch.auth()
const event = await firstbatch.createEvent("MyEvent", EventTypes.AIRDROP)
await event.attachGate(new Gate(PersonhoodMap["rank_3"]))
await firstbatch.addGate(event)
}
addGate()
In order to add rules to an event, use the following code. Multiple rules can be attached to a single event.
Python
Node
from firstbatch import EventTypes, Rule
event = fb.create_event(name="CustomPersonaEvent", event_type=EventTypes.AIRDROP)
# Tether ownership, ERC-20
rule = Rule(address="0xdAC17F958D2ee523a2206206994597C13D831ec7", amount=35)
event.attach_rule(rule)
# Azuki ownership, NFT
rule = Rule(address="0xED5AF388653567Af2F388E6224dC7C4b3241C544", amount=1)
event.attach_rule(rule)
fb.update_rules(event)
fb.boot_event(event)
const {FirstbatchClient, EventTypes, Rule} = require('./index');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function addRule(){
await firstbatch.auth()
const event = await firstbatch.createEvent("MyEvent", EventTypes.AIRDROP)
// Tether ownership, ERC-20
let rule = new Rule("0xdAC17F958D2ee523a2206206994597C13D831ec7", 35)
await event.attachRule(rule);
// Azuki ownership, NFT
rule = new Rule("0xED5AF388653567Af2F388E6224dC7C4b3241C544", 1)
await event.attachRule(rule)
await firstbatch.updateRules(event)
}
addRule()
Rules and gates can be attached to a single event at the same time.

Permission Management

FirstBatch deploys DApp-specific contracts on Polygon to provide permission management. After creating and deploying events, DApps can do simple read calls to their provided contract address to get access information for wallet_ids.
DApp contracts contain:
function isUserEventEligible(bytes32 eventId, address userAddress) external view onlyRole(DAPP_ROLE) whenNotPaused returns(bool) {
return isEventEligible[eventId][userAddress];
}
DApps can simply use event_id and wallet address to check if a user participated in the event. This allows complete control with frontend-only applications.
A sample using Alchemy API (Javascript)
DApps require:
  • Registered admin wallet address (Owned by DApp)
  • Contract ABI
  • Contract Address
To make the call.
const { createAlchemyWeb3 } = require("@alch/alchemy-web3")
let DAppEventABI = <ABI> // ABI will be provided with registration
let DAppEventAddress = "DAPP_CONTRACT_ADDRESS"
let DAppAdmin = "REGISTERED_WALLET"
async function getEventEligibility() {
const web3 = await createAlchemyWeb3(<ALCHEMY_KEY>)
const dappEvent = await new web3.eth.Contract(DappEventABI.abi, DAppEventAddress)
const data = await dappEvent.methods.isUserEventEligible(event_id, wallet_id).call({from:DAppAdmin})
console.log(data)
}
getEventEligibility()
.then(() => {
console.log("Success")
process.exit(0)
})
.catch((error) => {
console.error(error)
process.exit(1)
})