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.
Overview
Section titled “Overview”This mandate acts as an oracle for off-chain governance state on Snapshot. It:
- Queries the Snapshot GraphQL API using Chainlink Functions.
- Verifies that a proposal with the given ID exists.
- Checks that the proposal status is “pending”.
- Ensures that the proposal includes the specified voting choice.
- If verified, it triggers a fulfillment on the Powers contract (currently without executing any downstream actions).
Configuration
Section titled “Configuration”When adopting a Snapshot_CheckSnapExists instance, the following parameters are required:
spaceId(string): The Snapshot Space ID (e.g., “yam.eth”).subscriptionId(uint64): The Chainlink Functions subscription ID.gasLimit(uint32): The gas limit for the Chainlink Functions callback.donID(bytes32): The Chainlink DON (Decentralized Oracle Network) ID.
Proposing an Action
Section titled “Proposing an Action”When calling the mandate, the following parameters must be provided:
proposalId(string): The ID of the Snapshot proposal to verify.choice(string): The voting choice to check for (e.g., “Yes”).targets(address[]): (Unused) Intended for future execution logic.values(uint256[]): (Unused) Intended for future execution logic.calldatas(bytes[]): (Unused) Intended for future execution logic.govDescription(string): A description of the governance action.
Execution Flow
Section titled “Execution Flow”-
Request Initiation (
handleRequest)- Prepares arguments for the Chainlink Function:
proposalIdandchoice. - Initiates the request to the Chainlink Oracle.
- Prepares arguments for the Chainlink Function:
-
Oracle Call (
_externalCall)- Sends the request to Chainlink.
- The off-chain script queries
https://hub.snapshot.org/graphqlto fetch proposal details.
-
Verification & Fulfillment (
fulfillRequest)- Off-Chain Checks:
- Does the proposal exist?
- Is the state “pending”?
- Does the
choicesarray include the requestedchoice?
- On-Chain Verification:
- Receives the result (“true” or error message).
- If “true”, calls
powers.fulfill.
- Note: The current implementation executes
fulfillwith empty action arrays, meaning no state changes occur on the Powers contract other than marking the async action as complete.
- Off-Chain Checks:
Technical Specifications
Section titled “Technical Specifications”Chainlink Source
Section titled “Chainlink Source”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/ ...Functions
Section titled “Functions”initializeMandate
Section titled “initializeMandate”function initializeMandate( uint16 index, string memory nameDescription, bytes memory inputParams, bytes memory config) public override- Initializes Chainlink configuration.
- Sets input parameters.
handleRequest
Section titled “handleRequest”function handleRequest(...) public view virtual override returns (...)- Prepares Chainlink request arguments.
fulfillRequest
Section titled “fulfillRequest”function fulfillRequest(bytes32 requestId, bytes memory response, bytes memory err) internal override- Callback from Chainlink.
- Verifies response is “true”.
- Calls
powers.fulfill.
Error Conditions
Section titled “Error Conditions”-
Chainlink Errors
- “Proposal not recognised.”
- “Proposal not pending.”
- “Choice not present.”
- “Request failed” (API error).
-
Validation Errors
- “No response from the API”
- “Request not found”
Current Deployments
Section titled “Current Deployments”| Chain ID | Chain Name | Address |
|---|---|---|