[PlatONE Alliance Chain Usage Guide] How to use the contract naming system cns through the chain interaction tool platonecli?

PlatONE is a new-generation consortium blockchain platform featuring privacy computing jointly created by Wanxiang Blockchain and Matrix Element. It supports enterprise-level applications. It was officially open-sourced and put into use in actual products in September 2019. At present, PlatONE's single-chain TPS has exceeded 50,000, and it has been recognized by the Ministry of Industry and Information Technology of the People's Republic of China and passed the functional certification and testing certification of the China Electronics Standardization Institute.

We will lead you into PlatONE through a series of popular science articles, from entry to mastery. Last week, we have introduced the method of operating user and role permissions through the chain interaction tool platonecil . Today we will learn how to use platonecil to perform related operations on the contract naming system service.
 

cns resolve cns resolve

Description : Parse the corresponding account address through the contract name and version number (default is "latest"). A contract name can correspond to multiple (registered) contract addresses, and the corresponding contract address can be parsed through the version number, but the version number corresponding to the contract name that has been cancelled in the cns platform cannot be parsed into the corresponding account address.

Parameters :

  • Required parameters:

<name>: The contract name of the contract registered in cns
  • Optional parameters:

--ver string: The version number of the contract registered in cns, the default is "latest"

Operation :

# Query the latest 
version./platonecli cns resolve "test" --keyfile ../conf/keyfile.json 
​#
 Query the specified 
version./platonecli cns resolve "test" --version "1.0.0.0" --keyfile ../ conf/keyfile.json

Output result :

result: <address> 
​#
 The version corresponding to the contract name has been cancelled 
result: <null>

cns registercns register

Description : Register the contract in the cns platform. The registered contract can be called and executed not only through the contract account address, but also through its corresponding contract name.

Parameters :

  • Required parameters:

<name>: The contract name registered in cns 
<version>: The version number registered in cns, (supplement). Format: "XXXX" 
<address>: Account address of the contract to be registered

Operation :

./platonecli cns register "test" "1.0.0.0" "0x2ee8d0545ebd20f9a992ff54cb0f21a153539206"  --keyfile ../conf/keyfile.json

Output result :

{
  "status": "Operation Succeeded",
  "logs": [
      "Event [CNS] Notify: 0 [CNS] cns register succeed "
  ],
  "blockNumber": 190,
  "GasUsed": 105856,
  "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
  "To": "0x0000000000000000000000000000000000000011",
  "TxHash": ""
}

cns redirect cns redirect

Description : Specify the contract version corresponding to the cns name.

Parameters :

  • Required parameters:

<name>: The contract name registered in cns 
<version>: The version number registered in cns. Format: "XXXX" 
<address>: Account address of the contract to be registered

Operation :

./platonecli cns register "test" "1.1.0.0" "0x2ee8d0545ebd20f9a992ff54cb0f21a153539206"  --keyfile ../conf/keyfile.json

Output result :

{
  "status": "Operation Succeeded",
  "logs": [
      "Event [CNS] Notify: 0 [CNS] cns redirect succeed "
  ],
  "blockNumber": 191,
  "GasUsed": 102864,
  "From": "0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
  "To": "0x0000000000000000000000000000000000000011",
  "TxHash": ""
}

cns information querycns query

Description : Filter and query the cns registration information according to the query key value and auxiliary options, and return all data objects that match successfully.

Parameters :

  • Optional parameters:

--contract <address>: query key, query by contract account address or contract name 
--user <address>: query key, query by user account address, query the contract registered by the user in cns 
--all: query key , display all registered objects in all cns (do not display the information that has been cancelled) 
--pageNum: display page page number 
--pageSize: display page size

Operation :

# 1 Query registered contracts./platonecli 
cns query --all --keyfile ../conf/keyfile.json 
# 2 Query by contract name - query the registration history of the 
name./platonecli cns query --contract "test" --keyfile ../conf/keyfile.json 
# 3 Query by registrant 
./platonecli cns query "0x01a369998e4a141c5e2b40dbcbaf4a601d57cfa5" --pageNum "10" --pageSize "0" --keyfile ../conf/keyfile.json 
# 4 Query by contract address 
## Currently the interface is to query contracts that have not been cancelled by 
address./platonecli cns query --contract "0x01a369998e4a141c5e2b40dbcbaf4a601d57cfa5" --keyfile ../conf/keyfile.json

Output result :

{
  "code":0,
  "msg":"success",
  "data":[{
      "name":"eeeee",
      "version":"0.0.0.1",
      "address":"0x12a0de8326d814e1569d6a0e111be02b19741694",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1600758772
  },
  {
      "name":"tofu",
      "version":"0.0.0.1",
      "address":"0x9185686d2a1fc1bbadaba646d7323f597fae0073",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1600761759
  },
  {
      "name":"test",
      "version":"0.0.0.2",
      "address":"0x12a0de8326d814e1569d6a0e111be02b19741694",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1600918255
  },
  {
      "name":"test",
      "version":"0.0.0.3",
      "address":"0xdb907806b906cfaa9049e5774e03263c6ff203e8",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1601350402
  },
  {
      "name":"damn",
      "version":"0.0.0.1",
      "address":"0xe3471eace6b0eca6150d3a41051d8c7212c35da7",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1601364209
  },
  {
      "name":"ljj",
      "version":"1.0.0.0",
      "address":"0x388d05bad3aab0fdd4a5256d4732c2129037cf19",
      "origin":"0x8d4d2ed9ca6c6279bab46be1624cf7adbab89e18",
      "create_time":1602234874
  }]
}

cns state query cns state

Description : Query the registration status of a contract in the cns platform through the query key. The registration status is divided into: registered (returns true) or cancelled (returns false).

Parameters :

  • Required parameters:

<contract>: query key, query according to contract account address or contract account name

Operation :

# Check whether the contract address is registered./platonecli 
cns state "0x2ee8d0545ebd20f9a992ff54cb0f21a153539206" --keyfile ../conf/keyfile.json 
# Check whether the contract name is registered./platonecli 
cns state "test" --keyfile ../conf/keyfile. json

Output result :

# Registered 
result: the contract is registered in CNS 
# Unregistered 
result: the contract is not registered in CNS
{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324043821&siteId=291194637