All pages
Powered by GitBook
1 of 1

Loading...

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" to get started. Thereby, the restricted areas of the contract can only be called by the owner of the contract.

Get smart contract 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.

  • 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.

  • 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

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

account

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

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: RINKEBY, ROPSTEN, MUMBAI, SHIMMEREVM

contract: smart contract address

role

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

  • 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.

  • 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.

  • Path parameter:

chain: chain to work with.

Main chains: ETHEREUM, POLYGON

Testnet chains: SEPOLIA, GOERLI, MUMBAI, SHIMMEREVM

contract: smart contract address

  • account: [string] the new owner address.

: an account address

role: role name

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

  • account: [string] an account address.

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

  • account: [string] an account address.

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

  • account: [string] an account address.

during deployment
curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xf277BE034881eE38A9b270E5b6C5c6f333Af2517/owner"
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"}'
{
  "account": "string"
}
curl -X POST "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xf277BE034881eE38A9b270E5b6C5c6f333Af2517/ownershipRenounce" 
curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/MUMBAI/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/account/0x8448Ff4b2733b52f62d81ca46d64bD16786299Cd/role/MINTING_ROLE" 
curl -X GET "http://0.0.0.0:7000/nftkit/nft/accessControl/chain/ETHEREUM/contract/0xDc22fE8b277c03B5Af231b6a049631a06961F20d/role/METADATA_UPDATER_ROLE/admin" 
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"}'
{
  "role": "string",
  "account": "string"
}
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"}'
{
  "role": "string",
  "account": "string"
}
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"}'
{
  "role": "string",
  "account": "string"
}