FirstBatch
Search…
⌃K

Events

FirstBatch works around events. All functionalities offered by FirstBatch are attached to event objects. You can start creating events with:
Python
Node
from firstbatch import FirstBatchClient, EventTypes
public_key = "YOUR_PUBLIC_KEY"
secret = "YOUR_SECRET"
fb = FirstBatchClient(public_key, secret)
event = fb.create_event(name="MyEvent", event_type=EventTypes.AIRDROP)
const {FirstbatchClient, EventTypes} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function createEvent(){
await firstbatch.auth()
const event = await firstbatch.createEvent("MyEvent", EventTypes.AIRDROP)
}
createEvent()
This creates an event object in starting (INIT) state and returns an event object on the client side. Event types are for clarification purposes on both the user end and the dapp end.
Events with INIT states are not active on the blockchain. They need to be booted for activation.
Through the FirstBatch client, users can add gates, add rules and update the state of the event. More on gates and rules.
Code below creates an event with no gates and boots it on-chain.
This event is joinable by every PNFT owner without any requirements.
Python
Node
from firstbatch import FirstBatchClient, EventTypes, Gate, PersonhoodMap
public_key = "YOUR_PUBLIC_KEY"
secret = "YOUR_SECRET"
fb = FirstBatchClient(public_key, secret)
event = fb.create_event(name="MyEvent", event_type=EventTypes.AIRDROP)
res = fb.boot_event(event)
#boot_event will return transaction hash
print(res["data"]["tx_hash"])
const {FirstbatchClient, EventTypes} = require('firstbatch');
const public_key = "YOUR_PUBLIC_KEY"
const secret = "YOUR_SECRET"
const firstbatch = new FirstbatchClient(public_key, secret)
async function bootEvent(){
await firstbatch.auth()
const event = await firstbatch.createEvent("MyEvent", EventTypes.AIRDROP)
const res = await firstbatch.bootEvent(event)
console.log(res["data"]["tx_hash"])
}
bootEvent()
After the event is booted, the event state will be PAUSED by default. Paused events are editable, but not open to users for participation.
In order to make events available for participation, activate event by:
Python
Node
from firstbatch import StateEnum
fb.update_state(event, StateEnum.ACTIVE)
const {StateEnum} = require('firstbatch');
await firstbatch.updateState(event, StateEnum.ACTIVE)
Once event is active, you can generate links to share with PNFT owners for participation.
Python
Node
link = fb.get_event_link(event)["data"]["link"]
const link = await firstbatch.getEventLink(event)["data"]["link"]
Links are in the following form and will display a screen for users to generate proofs or directly participate in events.
https://access.firstbatch.xyz/event?code=09kp5apni4
To get previous events, and pause last created event:
Python
Node
# Get all events
events = fb.get_all_events()
# Pause lastly created event
fb.update_state(events[-1], StateEnum.PAUSED)
// Get all events
const events = await firstbatch.getAllEvents();
// Pause lastly created event
await fb.updateState(events[events.length - 1], StateEnum.PAUSED)