Skip to content

Snapshot_CheckSnapExists

Snapshot_CheckSnapExists is an async mandate that uses Chainlink Functions to verify the existence and state of a Snapshot proposal. It confirms that a proposal exists, is currently pending, and includes a specific voting choice.

This mandate acts as an oracle for off-chain governance state on Snapshot. It:

  1. Queries the Snapshot GraphQL API using Chainlink Functions.
  2. Verifies that a proposal with the given ID exists.
  3. Checks that the proposal status is “pending”.
  4. Ensures that the proposal includes the specified voting choice.
  5. If verified, it triggers a fulfillment on the Powers contract (currently without executing any downstream actions).

When adopting a Snapshot_CheckSnapExists instance, the following parameters are required:

  1. spaceId (string): The Snapshot Space ID (e.g., “yam.eth”).
  2. subscriptionId (uint64): The Chainlink Functions subscription ID.
  3. gasLimit (uint32): The gas limit for the Chainlink Functions callback.
  4. donID (bytes32): The Chainlink DON (Decentralized Oracle Network) ID.

When calling the mandate, the following parameters must be provided:

  1. proposalId (string): The ID of the Snapshot proposal to verify.
  2. choice (string): The voting choice to check for (e.g., “Yes”).
  3. targets (address[]): (Unused) Intended for future execution logic.
  4. values (uint256[]): (Unused) Intended for future execution logic.
  5. calldatas (bytes[]): (Unused) Intended for future execution logic.
  6. govDescription (string): A description of the governance action.
  1. Request Initiation (handleRequest)

    • Prepares arguments for the Chainlink Function: proposalId and choice.
    • Initiates the request to the Chainlink Oracle.
  2. Oracle Call (_externalCall)

    • Sends the request to Chainlink.
    • The off-chain script queries https://hub.snapshot.org/graphql to fetch proposal details.
  3. Verification & Fulfillment (fulfillRequest)

    • Off-Chain Checks:
      • Does the proposal exist?
      • Is the state “pending”?
      • Does the choices array include the requested choice?
    • On-Chain Verification:
      • Receives the result (“true” or error message).
      • If “true”, calls powers.fulfill.
    • Note: The current implementation executes fulfill with empty action arrays, meaning no state changes occur on the Powers contract other than marking the async action as complete.

The mandate uses a hardcoded JavaScript source to query the Snapshot API:

const proposalId = args[0];
const choice = args[1];
// ... queries https://hub.snapshot.org/graphql/ ...
function initializeMandate(
uint16 index,
string memory nameDescription,
bytes memory inputParams,
bytes memory config
) public override
  • Initializes Chainlink configuration.
  • Sets input parameters.
function handleRequest(...) public view virtual override returns (...)
  • Prepares Chainlink request arguments.
function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override
  • Callback from Chainlink.
  • Verifies response is “true”.
  • Calls powers.fulfill.
  1. Chainlink Errors

    • “Proposal not recognised.”
    • “Proposal not pending.”
    • “Choice not present.”
    • “Request failed” (API error).
  2. Validation Errors

    • “No response from the API”
    • “Request not found”
Chain IDChain NameAddress