Contract query

Call any read function of a contract and check the answer.

A contract query calls a read function of any smart contract with the member's wallet address and checks what it returns. Use it when no ready-made requirement fits: staking positions, protocol registrations, eligibility flags, scores kept onchain.

What it's for

If your contract can answer "does this address qualify?" through a function, a contract query turns that answer into a role. Common cases are isRegistered(address) returning true, balanceOf(address) on a staking contract, or userInfo(uint256,address) returning a deposited amount.

Set it up

  1. Under Who gets it, press Requirement and pick Contract query.
  2. Pick the chain the contract is deployed on.
  3. Paste the Contract address. If the contract is verified on a block explorer, Guild loads its read functions and you pick one. Otherwise, fill the form in by hand with the function's signature, for example userInfo(uint256,address)(uint256,uint256).
  4. Fill in Input parameters. Put USER_ADDRESS wherever the member's wallet address goes. Guild replaces it with each connected wallet when it checks, and a query without it is rejected.
  5. Under Output to check, pick which returned value to read and its type: an address, a number (bigint) or a boolean. Functions that return several values number them from 0: index 0 is the first value, index 1 the second.
  6. Set what the value must be, then press Add requirement.

Gotchas

  • Guild calls the function without sending a transaction, so it must not be payable, and anything it would change is thrown away.
  • If the function reverts for a wallet, Guild gets no answer for it, and that wallet can't earn the role.
  • Numbers come back in the contract's raw units. A token amount with 18 decimals reads as the amount followed by 18 zeros.

Examples

  • Registered users: isRegistered(address) with params ["USER_ADDRESS"], output boolean equals true.
  • Stakers: balanceOf(address) on your staking contract with ["USER_ADDRESS"], output bigint at least 1000000000000000000 (1 token with 18 decimals).
  • Pool depositors: userInfo(uint256,address) with [0, "USER_ADDRESS"], output index 0, bigint greater than 0.

Requirement type

This is the exact type the requirement picker offers, with its fields as you see them in the form.

Chains (53): Ethereum, OP Mainnet, Cronos Mainnet, Rootstock Mainnet, LUKSO, XDC Network, BNB Smart Chain, Gnosis, Polygon, Sonic, Manta Pacific Mainnet, Mint, X Layer Mainnet, opBNB, Boba Network, Filecoin Mainnet, ZKsync Era, World Chain, Astar EVM, Hyper EVM, Metis, Polygon zkEVM, Core Dao, Lisk, Moonbeam, Moonriver, Sei Network, Soneium Mainnet, Ronin, Kava EVM, Mantle, Superseed, MegaETH, ZetaChain, Cyber, Klaytn, Base, IOTA EVM, Mode Mainnet, Arbitrum One, Celo, Avalanche, Sophon, Ink, Linea Mainnet, Taiko Mainnet, Syndicate Commons, Scroll, Zora, Neon EVM MainNet, Monad Mainnet, Hemi, Harmony One. See supported chains.

Contract query

Members connect a wallet to be checked.

Field Type Details
Contract Address Text The contract address For example 0xb0d502e938ed5f4df2e681fe6e419ff29631d62b.
Method Text The text signature of the method to call For example userInfo(uint256,address)(uint256,uint256).
Output Index Number, optional The index of the output to return if the method return multiple values in an array
Params Text The parameters to pass to the method. You can pass in the data point's account id as a parameter with the keyword USER_ADDRESS For example [1234, "0x1234567890123456789012345678901234567890", "USER_ADDRESS"].
Select what to check Choice One of: Output Address, Output Bigint, Output Boolean.

All Guild docs