Smart Contract | Access Control

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

Swagger Doc | ReDoc

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" during deployment 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

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

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

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

Last updated