World ID

Anonymous Actions

The World ID protocol provides developers flexibility in the types of actions they would like to verify. In addition to sign in, developers can create anonymous actions to verify any arbitrary action a user might take in their applications. Some examples include:

  • Claiming a one-time discount for a purchase
  • Allowing user's to vote in a poll, but only vote per user
  • Sharing an invitation to join a platform, limited to five total invites

To demonstrate the power of actions, take the voting example. Imagine you are building a website to host polls for a local organization, but you'd like votes to be anonymous. By using a new action for each vote, you can enforce that users only vote once in each ballot, while also ensuring that there is no way to correlate a user's cast ballots across votes.

A diagram showcasing an application taking advantage of anonymous actions

Configuration

Anonymous actions can either be configured via the developer portal, or on-the-fly through IDKit. Either approach provides the same feature set. Creating actions on the Developer Portal is generally recommended, but setting on-the-fly is best for dynamic contexts. For example, this feature is used in Discord Bouncer to generate an action for each Discord server that installs the bot, because we don't know all the servers in advance.

Developer Portal

Once your application is registered in the developer portal, you may add additional actions to it. You must provide the following values:

  • Action: The stringified action to be taken by the user
  • Max Verifications: The number of times a user can take this action. A value of 0 indicates that unlimited verifications can take place.

The "Description" field is shown to your user in the World app as they sign with their World ID, alongside your application logo. Make sure to fully describe the exact action the user is taking.

You can also specify the number of times a user can complete an action, or allow an unlimited amount of verifications to take place.

Once complete, make sure you pass the same registered value for action to IDKit in it's props.

On-The-Fly

To accommodate dynamic content, actions can also be created on-the-fly as a user completes a World ID verification. Simply pass the desired action value in IDKit's props. A new action will automatically be created and tracked, and will appear the next time you log into the developer portal.

As an example, a custom action version of IDKit may look like:

const getUserChoice = userId => {
	const choice = userChoices['userId']
	return choice
}

return (
	<IDKitWidget
		onSuccess={onSuccess}
		handleVerify={handleProof}
		action={getUserChoice(userId)}
		app_id="app_staging_7550e829082fc558e112e0620c1c7a59"
	/>
)

To perform dynamic on-chain actions, please reference the on-chain section of the documentation.