🚧Tokengating
Documentation for ODK In World Gating using objects and NFTs
Last updated
Documentation for ODK In World Gating using objects and NFTs
Last updated
In-world gating uses the base class BPM_GatedAreaBase
.
Note: In order to use this in the editor, the blueprint needs access to online datasources, therefore, you must be signed in and not in offline mode.
This can be done by opening Editor Preferences > Sign-In Settings
and adding your credentials.
Objects and NFTs serve as two distinct types of assets that grant access to specific areas.
Objects are project-specific assets stored within a project's datasource and can be queried by supplying the datasource ID and Object ID.
These Objects are unique to each project and cannot be transferred between different projects.
NFTs, on the other hand, are assets stored in a user's linked wallet, making them accessible across multiple projects. Unlike Objects, NFTs offer cross-project utility, allowing players to unlock content or areas in any project where the NFT is recognized.
There are two methods to define access to the area:
Within the project there are various GatedConditions. These components can be dropped onto the BPM_GatedAreaBase actors and will be used to check for access.
The base actor supports multiple condition components and has a Multiple Conditions Operator variable.
When this variable is set to “And”, all condition components must return true in order for access to be granted.
When this variable is set to “Or”, any condition must return true to allow access.
In the above example, the actor has two condition components:
The Multiple Conditions Operator is set to “Or” which, in this example, means that the user can either own the object OR be a director (or both) to gain access.
In this example we are checking that the user owns a project specific “Object” stored in the project datasource.
The BPM_GatedAreaBase base class contains a function named AllowAccess that can be overridden by child classes to check various conditions.
In this example: we have overridden the AllowAccess function to check if the time is between 12pm and 4pm
more examples of overriding the AllowAccess function can be found on the Advanced Gating Logic page
BPC_GatedCondition_ObjectOwnership
checks that the user owns a specific object in a specific datasource. The datasource and object ID can be set directly on the component
BPC_GatedCondition_Role
checks that the current users role exists in an array of strings, in this example we are checking if the current user is a “Director”
NFT ownership (items in a linked wallet) can be checked in a number of ways.
BPC_GatedCondition_NFTOwnership_ByAddress
checks for the contract address, this is not case sensitive
BPC_GatedCondition_NFTOwnership_ByChain
Is case sensitive, and not Chain ID. So Polygon, Ethereum work, but not ETH
BPC_GatedCondition_NFTOwnership_ByCollection
is also case sensitive
BPC_GatedCondition_NFTOwnership_ByTokenID
is the number of the token
NFT Metadata can be queried to check if the object has a trait with a specific name or value.
Below is an example object with some metadata
Using BPC_GatedCondition_NFTOwnership_ByTrait
we can check that the object contains a trait called "Ears" like so ...
Additionally, we can check for specific values using BPC_GatedCondition_NFTOwnership_ByMatchingTrait
to check that the object has a trait name of "Ears" and more specifically, that the ears are of type "Pointy" like so...
The functions included in the blueprint function library for checking for traits are
Auth Client Owns Object with Trait
and Auth Client Owns Object with MatchingTrait
and both return a boolean and an array of matching objects