← Protocols
Guild.xyz
01Description

Token-gated communities and roles. Membership-layer protocol that gates Discord, Telegram, GitHub, and custom platforms on token, NFT, POAP, and onchain criteria.

02Best for
  • 01Discord/Telegram token gating
  • 02role-based community access
  • 03multi-platform single-source-of-truth gating
  • 04automated role syncing
  • 05DAO/community membership
03Install
  • pnpm add @guildxyz/sdk viem
04Environment variables
VariableScopeDescription
GUILD_API_KEYServerGuild API key (requested from Guild team for higher rate limits).
GUILD_SIGNER_PRIVATE_KEYServerPrivate key used to sign authenticated SDK requests (server-side only).
NEXT_PUBLIC_GUILD_IDClientNumeric guild ID or url-name slug.
05Prompt snippet
Use `@guildxyz/sdk` (v2+) for membership and role gating. Instantiate the client with `createGuildClient('YourApp')` and authenticate with a viem `LocalAccount` for write operations. Read-only: `client.guild.get(guildIdOrUrlName)`, `client.guild.role.get(guildId, roleId)`, `client.user.getMemberships(address)`. Write: `client.guild.create({ name, urlName, roles, guildPlatforms }, signerFn)` where `guildPlatforms` describes Discord/Telegram targets and `roles[].requirements` defines token/NFT/POAP/balance gates. Sync user role state with `client.user.join(guildId, address, signerFn)`.
06Gotchas
  • SDK v1.x.x is deprecated and stopped working in 2024 — use the v2+ `@guildxyz/sdk` only.
  • Auth uses EIP-191 personal_sign over a Guild-specific message; passing the wrong signer type silently fails with 401.
  • Discord/Telegram bot must be invited to the target server with the right permissions before role-sync calls work.
  • Token requirements re-check on a cooldown (typically minutes-to-hours) — instant role removal on token transfer is not guaranteed.
  • Public API is rate-limited per IP; partners should request an API key for higher quotas.
  • Some chains require Guild's indexer to support them — exotic L2s may have requirement check delays or be unsupported.
07Alternatives