Smart Contract | Access Control
The access control of your contract is an important concept that governs many features provided by your smart contract.
Almost every smart contract must have an access control mechanism. We provide two:
Ownership
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.
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
: 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.
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.
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
Last updated