Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Gatekeeper

Utilities for managing sales and executing purchases on the Gatekeeper protocol.

import { Gatekeeper } from '@sceneinfrastructure/sdk'

Encode Functions

Functions for encoding calls to be executed via callGatekeeper.

registerSale and updateSale can only be called by the token contract. Use Gatekeeper1155.callGatekeeper (requires ADMIN_ROLE or owner) with the encoded data. During deployment, include the call via Factory.encodeCallGatekeeper.

encodeRegisterSale

Encodes a registerSale call for registering new sales.

import { Gatekeeper } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const data = Gatekeeper.encodeRegisterSale({
  saleKey,
  saleState: {
    startTime: 1n,
    endTime: 9999999999n,
    quantity: 100,
    price: 1000000n,
    approvers: [],
  },
})

Parameters

ParameterTypeDescription
saleKeySaleKeySale identifier struct
saleStateSaleStateInitial sale configuration

encodeUpdateSale

Encodes an updateSale call for modifying existing sales.

import { Gatekeeper } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const data = Gatekeeper.encodeUpdateSale({
  saleKey,
  saleState: {
    startTime: 1n,
    endTime: BigInt(Math.floor(Date.now() / 1000)), // End now
    quantity: 0,
    price: 0n,
    approvers: [],
  },
})

Purchase Functions

preparePurchase

Prepares a purchase transaction for open sales (no approval required).

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
// Raw calldata
const { to, data } = Gatekeeper.preparePurchase({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  purchaseParams: {
    recipient: '0x4567890123456789012345678901234567890123',
    referrer: '0x0000000000000000000000000000000000000000',
    quantity: 1,
  },
})
 
// Viem args
const result = Gatekeeper.preparePurchase({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  purchaseParams: {
    recipient: '0x4567890123456789012345678901234567890123',
    referrer: '0x0000000000000000000000000000000000000000',
    quantity: 1,
  },
  as: 'args',
})

Parameters

ParameterTypeDescription
gatekeeperAddressGatekeeper contract address
saleKeySaleKeySale identifier
purchaseParamsPurchaseParamsPurchase configuration
as'data' | 'args'Output format

preparePurchaseWithApproval

Prepares a purchase with EIP-712 approval signature.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const { to, data } = Gatekeeper.preparePurchaseWithApproval({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  purchaseParams: {
    recipient: '0x4567890123456789012345678901234567890123',
    referrer: '0x0000000000000000000000000000000000000000',
    quantity: 1,
  },
  signatureParams: {
    deadline: BigInt(Math.floor(Date.now() / 1000) + 900),
    salt: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
    signature: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12',
  },
})

Parameters

ParameterTypeDescription
gatekeeperAddressGatekeeper contract address
saleKeySaleKeySale identifier
purchaseParamsPurchaseParamsPurchase configuration
signatureParamsApprovalSignatureParamsEIP-712 signature data
as'data' | 'args'Output format

Fund Functions

prepareWithdraw

Prepares a withdrawal of accumulated funds.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const { to, data } = Gatekeeper.prepareWithdraw({
  gatekeeper: gatekeeperAddress[chainId],
  currency: '0x1111111111111111111111111111111111111111',
  amount: 1000000n,
})

Parameters

ParameterTypeDescription
gatekeeperAddressGatekeeper contract address
currencyAddressCurrency token address
amountbigintAmount to withdraw

prepareWithdrawProtocol

Prepares withdrawal of protocol fees (owner only).

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const { to, data } = Gatekeeper.prepareWithdrawProtocol({
  gatekeeper: gatekeeperAddress[chainId],
  currency: '0x1111111111111111111111111111111111111111',
})

View Functions

prepareGetPrice

Prepares a price calculation query.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const { to, functionName, args } = Gatekeeper.prepareGetPrice({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  purchaseParams: {
    recipient: '0x4567890123456789012345678901234567890123',
    referrer: '0x5678901234567890123456789012345678901234',
    quantity: 1,
  },
  as: 'args',
})

Returns (from contract):

  • totalPrice - Total amount due
  • subtotal - Base price
  • protocolFee - Protocol fee amount
  • vendorFee - Vendor fee amount
  • referrerFee - Referrer fee amount
  • salesTax - Sales tax amount

prepareGetSale

Prepares a sale state query.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const { to, functionName, args } = Gatekeeper.prepareGetSale({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  as: 'args',
})

prepareIsSaleRegistered

Checks if a sale is registered.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const saleKey = {
  token: '0x1234567890123456789012345678901234567890', // Your deployed contract
  vendorFeeBps: 0,
  referralFeeBps: 0,
  salesTaxBps: 0,
  vendor: '0x2345678901234567890123456789012345678901',
  nonce: 1n,
  currency: '0x1111111111111111111111111111111111111111',
  fundsRecipient: '0x3456789012345678901234567890123456789012',
  tokenId: 1n,
} as const
 
const { to, functionName, args } = Gatekeeper.prepareIsSaleRegistered({
  gatekeeper: gatekeeperAddress[chainId],
  saleKey,
  as: 'args',
})

prepareDomainSeparator

Gets the EIP-712 domain separator.

import { Gatekeeper, gatekeeperAddress } from '@sceneinfrastructure/sdk'
 
const chainId = 8453 // Base
 
const { to, functionName, args } = Gatekeeper.prepareDomainSeparator({
  gatekeeper: gatekeeperAddress[chainId],
  as: 'args',
})