NFT verification with OPA

1. Via REST API

Add new policy

After the development of a policy using Rego, we need to add it to the NFT Kit.

API Doc

Swagger Doc | ReDoc

Curl call example

curl -X POST "https://nftkit.walt-test.cloud/v2/nftkit/nft/verifier/policies/create"  
 -H  "Content-Type: application/json" 
 -d "{\"name\":\"string\",\"description\":\"string\",\"input\":{\"additionalProp1\":{},\"additionalProp2\":{},\"additionalProp3\":{}},\"policy\":\"string\",\"policyQuery\":\"string\",\"policyEngine\":\"OPA\"}"

Body parameters:

{
  "name": "string",
  "description": "string",
  "input": {
    "additionalProp1": {},
    "additionalProp2": {},
    "additionalProp3": {}
  },
  "policy": "string",
  "policyQuery": "string",
  "policyEngine": "OPA"
}
  • name: [string] policy name.

  • description: [string] policy description.

  • input: [string] the input parameter of the open policy engine(OPA).

  • policy: [string] the policy Rego code that will be executed by OPA.

  • policyQuery: [string] the query parameter of the open policy engine(OPA).

  • policyEngine: [string] the engine who will run the policy.

Example:

Rego policy example:

Get policy list

Get the list of added policies.

API Doc

Swagger Doc | ReDoc

Curl call example

Apply a policy to a NFT

Execute a policy against a NFT metadata.

API Doc

Swagger Doc | ReDoc

Curl call example

Path parameters:

  • chain: [string] chain to work with. Either TEZOS, GHOSTNET, ETHEREUM, POLYGON, GOERLI, MUMBAI , TESTNET or MAINNET .

  • contract: [string] smart contract address

  • tokenId: [string] token id of the NFT

  • policyName: [string] the name of an already-added policy.

Example:

2. Via code

Setup

  1. You need have OPA in your local machine. Running OPA instructions.

  2. You need to add a path of OPA in the environment variable. When using IntelliJ IDEA:

Code examples

You can run an OPA policy against an NFT metadata from an EVM compatible or Tezos chains.

  • EVM compatible:

  • Tezos

Rego Code Example:

Last updated

Was this helpful?