curl -X GET "http://0.0.0.0:7000/v2/nftkit/nft/verifier/chain/{{chain}}/contract/{{contract}}/token/{{tokenId}}/policy/{{policyName}}/verification"
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:
curl -X GET "http://0.0.0.0:7000/v2/nftkit/nft/verifier/chain/TEZOS/contract/KT1U6EHmNxJTkvaWJ4ThczG4FSDaHC21ssvi/token/1462880/policy/policy1/verification"
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:
val inputs =mutableMapOf("type" to "T1", "model" to "M1","reference" to "R1")//in the IDP Kit, inputs parameterexist in idp-Config.jsonval policy ="/home/walid/Desktop/walt.id/opa/nft.rego"/*in the IDP Kit, policy parameter exist inidp-Config.json.Path file that contains rego code*/val query="data.app.nft.allow"//in the IDP Kit, query parameter exist in idp-Config.jsonval nftMetadata = NftService.getNftMetadata(Chain.MUMBAI,"0xf277BE034881eE38A9b270E5b6C5c6f333Af2517", BigInteger.valueOf(0))val nftMetadataWrapper=NftMetadataWrapper(evmNftMetadata = nftMetadata)val result= DynamicPolicy.doVerify(inputs, policy, query, nftMetadataWrapper) //true or false
Tezos
val inputs =mutableMapOf("type" to "T1", "model" to "M1","reference" to "R1")//in the IDP Kit, inputs parameterexist in idp-Config.jsonval policy ="/home/walid/Desktop/walt.id/opa/nft.rego"/*in the IDP Kit, policy parameter exist inidp-Config.json.Path file that contains rego code*/val query="data.app.nft.allow"//in the IDP Kit, query parameter exist in idp-Config.jsonval nftMetadata = TezosNftService.getNftTezosMetadata(Chain.TEZOS,"KT1RCzrLhBpdKXkyasKGpDTCcdbBTipUk77x", "1")val nftMetadataWrapper=NftMetadataWrapper(tezosNftMetadata = nftMetadata)val result= DynamicPolicy.doVerify(inputs, policy, query, nftMetadataWrapper) //true or false
Rego Code Example:
package app.nft
import future.keywords.if
default allow := false
allow if {
valid_datanft_type
valid_datanft_model
valid_datanft_reference
}
valid_datanft_type if input.type= data.type
valid_datanft_model if input.model= data.model
valid_datanft_reference if input.reference= data.reference