LogoLogo
ProductsCommunityGitHubShare Feedback
NFT Kit
NFT Kit
  • What is the NFT KIT?
    • Introduction
    • Non-Fungible Tokens (NFTs)
      • NFT | Basics
      • Technologies & Concepts
    • NFT Kit
      • NFT Kit | Basics
        • Overview
        • Functionality
      • NFT Flavors & Ecosystems
      • Architecture
        • Low-Level Service Abstraction
        • Ecosystem Abstraction
        • High-Level Interfaces / APIs
      • Use Cases
  • Getting started
    • Quick Start
  • Ecosystems
    • Ethereum | Polygon | Shimmer
      • Setup
      • NFT | Creation & Management
        • Smart Contract Deployment
        • Minting NFTs
        • Get NFT Metadata
        • Get Account Balance
        • Get Token Owner
        • Get Collection Info
        • Get NFTs by Account
      • NFT | Ownership Verification
        • Ownership Verification
        • Ownership Verification With Traits
      • Smart Contract | Extensions
        • Pausable
        • Burnable
      • Smart Contract | Access Control
        • Ownership
        • Role-Based Access Control
    • Ocean Protocol
      • Setup
      • NFT | Verification
      • NFT | Wallet
      • Architecture
    • Tezos
      • Architecture
      • NFT | Creation & Management
        • Smart Contract
        • Add Minter
        • NFT Minting
        • Fetch NFT metadata
        • Get account NFTs
        • Get contract metadata
      • NFT | Ownership Verification
        • NFT Ownership Verification
        • NFT Ownership Verification Within A Collection
        • NFT Ownership Verification With Traits
      • NFT | Wallet
      • Tutorials
        • Minting NFTs on Tezos
          • Setup
          • New Collection
          • First NFT
          • Verification
          • Wallet
    • Near Protocol
      • Architecture
        • Smart Contract
        • Blockchain NFTs operations
        • NFTs Queries
      • NFT | Creation & Management
        • NEAR Sub-Account
        • Deploy NFT Contract
        • NFT | Minting
      • Querying NFT information controller
        • Get NFTs for account
        • Get NFT By Token Id
        • Get NFT contract metadata
      • NFT | Wallet
      • Tutorials
        • Minting NFT on Near Protocol
          • Near Wallet Creation
          • Setup NFT-Kit
          • Create Sub-account
          • Smart Contract ( Collection )
          • Minting your first NFT
        • NFT Ownership Verification
        • Wallet
    • Polkadot
      • Architecture
      • Query NFTs
        • Unique network
          • Fetching Token id & Collection id
          • Fetching NFT metadata
        • Parachain Networks
          • Fetching Tokens by subscan
          • Fetching EVM ERC721 Collectibles by subscan
      • NFT | Ownership Verification
        • NFT ownership verification
        • NFT ownership verification within a collection
        • NFT ownership verification with traits
      • NFT | Wallet
        • Polkadot parachains
        • Polkadot EVM compatible parachains
    • Flow
      • Architecture
        • Cadence Scripts
        • NFT Operations (FCL)
      • Querying NFT information Controller
        • Get NFTs for an account
        • Get NFTs in Collection
        • Get NFT by Token Id
      • NFT | Ownership Verification
        • NFT ownership verification on Flow
        • NFT ownership verification in collection on Flow
      • NFT | Wallet
        • Flow Blockchain
    • Algorand
      • Architecture
        • Algorand Standard Assets (ASAs)
      • NFT | Creation & Management
        • Account Creation
        • NFT Creation (ARC3)
      • Querying Asset information
        • Get Assets for account
        • Get Asset Details
        • Get NFT Metadata by asset id
        • Get NFT by Asset id
      • NFT | Ownership Verification
        • NFT ownership verification
        • NFT ownership verification with traits
        • NFT ownership verification Based on Creator
        • NFT Metadata verification against a dynamic policy
      • NFT | Wallet
        • Algorand Blockchain
    • IPFS
  • Concepts
    • Soulbound Tokens (SBTs)
    • NFT verification with OPA
  • Configurations
    • Configuration Files
    • Gas Provider
  • Community
    • Discord
    • Twitter
    • Newsletter
    • GitHub Discussions
  • DEVELOPER RELATIONS
    • Roadmap
    • Contribute
    • Share Feedback
    • Contact
  • Product Editions
    • Open Source | Always Free
    • Enterprise | Self-Managed
    • Cloud Platform | Managed
Powered by GitBook
On this page
  • Ownership
  • Role-Based Access Control

Was this helpful?

Export as PDF
  1. Ecosystems
  2. Ethereum | Polygon | Shimmer

Smart Contract | Access Control

The access control of your contract is an important concept that governs many features provided by your smart contract.

PreviousSmart Contract | ExtensionsNextOcean Protocol

Last updated 1 year ago

Was this helpful?

|

Almost every smart contract must have an access control mechanism. We provide two:

  1. Ownership

  2. Role-Based Access Control

Ownership

"Ownership" is a simple approach to set up access control within your smart contract. You can easily provide the "accessControl" property with "OWNABLE" to get started. Thereby, the restricted areas of the contract can only be called by the owner of the contract.

Get smart contract owner.

curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xf277BE034881eE38A9b270E5b6C5c6f333Af2517/owner"

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

Transfer ownership of the contract to a new account.

curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xf277BE034881eE38A9b270E5b6C5c6f333Af2517/ownershipTransfer" \
-H  "Content-Type: application/json" \
-d '{"account":"0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd"}'

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

{
  "account": "string"
}

  • account: [string] the new owner address.

Renounce ownership of the smart contract.

curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xf277BE034881eE38A9b270E5b6C5c6f333Af2517/ownershipRenounce" 

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

Role-Based Access Control

"Role-Based Access Control" is a more complex approach than "Ownership" to manage access control. With this approach, you can define a hierarchy of roles, each allowed to perform a different set of actions. You can also assign multiple accounts to each role.

Verify if an account has been granted role

curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/account/0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd/role/MINTING_ROLE" 

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

account: an account address

role: role name

As we have a role hierarchy, You can use this API to get role admin that controls a sub role.

curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/ETHEREUM/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/role/METADATA_UPDATER_ROLE/admin" 

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

role: role name

Grant role to account. The caller must have role's admin role.

curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/grantrole" \
-H  "Content-Type: application/json" \
-d '{"role":"minting_role","account":"0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd"}'

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

{
  "role": "string",
  "account": "string"
}

  • role: [string] the role you want to grant to the specified account.

  • account: [string] an account address.

Revoke role to account. The caller must have role's admin role.

curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/revokeRole" \
-H  "Content-Type: application/json" \
-d '{"role":"METADATA_UPDATER_ROLE","account":"0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd"}'

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: SEPOLIA, GOERLI, MUMBAI, SHIMMEREVM

contract: smart contract address

{
  "role": "string",
  "account": "string"
}

  • role: [string] the role you want to revoke from the specified account.

  • account: [string] an account address.

Renounce role from the calling account.

curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/POLYGON/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/renounceRole" \
-H  "Content-Type: application/json" \
-d '{"role":"METADATA_UPDATER_ROLE","account":"0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd"}'

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: SEPOLIA, GOERLI, MUMBAI, SHIMMEREVM

contract: smart contract address

{
  "role": "string",
  "account": "string"
}

  • role: [string] the role you want to renounce from the specified account.

  • account: [string] an account address.

Swagger Doc
ReDoc
during deployment