PlatONE is a new generation of alliance blockchain platform characterized by privacy computing, which is jointly built by universal blockchain and matrix element. It supports enterprise applications. It has been officially open source in September 2019 and put into use in actual products. At present, PlatONE's single chain TPS has exceeded 50000, has been recognized by the Ministry of industry and information technology of the people's Republic of China, and has passed the functional certification and test certification of China Institute of electronic technology standardization.
We will lead you into PlatONE through a series of popular science articles, from introduction to mastery. This article mainly explains the method of user and role permission operation through the chain interaction tool platonecil to help you realize the functions of user registration, user information update, user information query, setting different role permissions and so on.
-
User action account
Operations related to the account address.
-
User registration account add
Description: conduct User registration for the account. The approved account address and its personal information will be recorded on the User platform.
Parameters:
-
Required parameters:
<account>: User account address <name>: user name
-
Optional parameters:
--tel: User telephone information --email: User mailbox information --organization string: User's organization
Operation:
./platonecli account add "0xb239401ecf8427f17c6de134d6a6bddd3100251f" "Alice" --phone "13111111111" --email "alice@wx.bc.com" --organization wxbc --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event addUser: 0 Success " ], "blockNumber": 227, "GasUsed": 113404, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
-
User information update account update
Description: update the user's phone, email and other related information. Ordinary users (users without roles / permissions) cannot modify the user's information. Only the administrator account can operate.
Parameters:
-
Required parameters:
<address>: (Select the user account address to update
-
Optional parameters:
--phone <number>: User telephone information (update) --email string: User mailbox information (update) --organization string: User's organization (Updated)
Operation:
# optional flags: ## Modify user phone ./platonecli account update "0xb239401ecf8427f17c6de134d6a6bddd3100251f" --phone "13241231233" --keyfile ../conf/keyfile.json ## Modify user mailbox ./platonecli account update "0xb239401ecf8427f17c6de134d6a6bddd3100251f" --email "123@qq.com" --keyfile ../conf/keyfile.json ## Modify the organization of the user ./platonecli account update "0xb239401ecf8427f17c6de134d6a6bddd3100251f" --organization "wxbc" --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event updateUserDescInfo: 0 Success " ], "blockNumber": 228, "GasUsed": 110548, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
-
User information query account query
Description: filter and query the information according to the query key value and auxiliary options, and return all successfully matched data objects
Parameters:
-
Optional parameter: user information query, used to update user information.
--user: Query key to query by user account address or account name (the returned result is unique) --all: Query all users
Operation:
User information and user role information are stored in different system contracts. After reconstruction, we associate user information and role information internally and then feed back to users.
-
After Refactoring:
# 1. Query user information through user account address ./platonecli account query --user "0xb239401ecf8427f17c6de134d6a6bddd3100251f" --keyfile ../conf/keyfile.json # 2. Query user information by user account name ./platonecli account query --user "Alice" --keyfile ../conf/keyfile.json
Output results:
{ "address":"0xb239401ecf8427f17c6de134d6a6bddd3100251f", "authorizer":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "name":"Alice" }
-
Role permission Operation role
Related operations for role permissions
-
Set super administrator privilege role setSuperAdmin
Warning: can only be set once
Description: after the chain is deployed, you can call this method to set super administrator permissions for the current account.
Operation:
./platonecli role setSuperAdmin --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event setSuperAdmin: Set SuperAdmin Succeed " ], "blockNumber": 2, "GasUsed": 102184, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
-
Transfer super administrator privilege role transfersuper admin
Description: transfer super administrator permissions (the caller must be the current super administrator).
Parameters:
-
Required parameters:
<address>: Super administrator address after transfer
Operation:
./platonecli role transferSuperAdmin "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18" --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event setSuperAdmin: Set SuperAdmin Succeed " ], "blockNumber": 2, "GasUsed": 102184, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
-
role addXXX
Description: add permissions for a specified role for an account address.
Parameters:
-
Required parameters:
<address>: Account address given role permission
Operation:
#Chain Administrator ./platonecli role addChainAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Group administrator ./platonecli role addGroupAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Node administrator ./platonecli role addNodeAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Contract administrator ./platonecli role addContractAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #General contract deployer ./platonecli role addContractDeployer 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event addGroupAdminByAddress: 0 Success " ], "blockNumber": 197, "GasUsed": 105788, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
-
Delete role delXXX
Description: delete the permission of the specified role for an account address.
Parameters:
-
Required parameters:
<address>: Account address given role permission
Operation:
#Chain Administrator ./platonecli role delChainAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Group administrator ./platonecli role delGroupAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Node administrator ./platonecli role delNodeAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #Contract administrator ./platonecli role delContractAdmin 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json #General contract deployer ./platonecli role delContractDeployer 0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18 --keyfile ../conf/keyfile.json
Output results:
{ "status": "Operation Succeeded", "logs": [ "Event delGroupAdminByAddress: 0 Success " ], "blockNumber": 198, "GasUsed": 105788, "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18", "To": "0x1000000000000000000000000000000000000001", "TxHash": "" }
Get permission address list role getAddrListOfRole
Description: get permission address list.
Parameters:
-
Required parameters:
<role>: Roles can and can only be"SUPER_ADMIN", "CHAIN_ADMIN", "GROUP_ADMIN", "NODE_ADMIN", "CONTRACT_ADMIN" , "CONTRACT_DEPLOYER"One of
Operation:
#With super_ Take admin as an example ./platonecli role getAddrListOfRole "SUPER_ADMIN" --keyfile ../conf/keyfile.json
Output results:
# With super_ Take admin as an example ["0x10ad2ec4831a1f89ec870a3224fead87cdb75931"]
-
Permission check role hasRole
Description: check whether an account address has the specified user permission.
Parameters:
-
Required parameters:
<address>: Account address to be checked <role>: Roles can and can only be"SUPER_ADMIN", "CHAIN_ADMIN", "GROUP_ADMIN", "NODE_ADMIN", "CONTRACT_ADMIN" , "CONTRACT_DEPLOYER"One of
Operation:
#With super_ Take admin as an example
./platonecli role hasRole 0x10ad2ec4831a1f89ec870a3224fead87cdb75931 SUPER_ADMIN --keyfile ../conf/keyfile.json
Output results:
#With super_ Take admin as an example #Have authority
result: 1
#No permission
result: 0
-
Get role getRoles permission
Description: obtain user permissions for an account address.
Parameters:
-
Required parameters:
<address>: Account address to be checked
Operation:
#With super_ Take admin as an example ./platonecli role getRoles 0x10ad2ec4831a1f89ec870a3224fead87cdb75931 --keyfile ../conf/keyfile.json
Output results:
["SUPER_ADMIN"]
click https://platone.wxblockchain.com/ , you can download the white paper "platform: a new generation of alliance blockchain platform based on privacy computing" to learn more about platform.