ContractNameService

https://github.com/zcom-cloud-blockchain/solidity/blob/master/contracts/ContractNameService.sol

Overview

ContractNameService (CNS) is a contract that returns the address of the target contract when queried by the contract name.

It acts like DNS (Domain Name System).

In order to use the CNS contract, you need to register it in the administration screen.

For details about registering on the administration screen, please check basic setting.

CNS Image

Processing Sequence

  • Sequence Diagram

    CNS - Seq

Since the address of the user who registers contracts in the CNS is limited only to the address by which the CNS is deployed (the address of the service provider), you can see that the contracts registered in the CNS are registered by the service provider.

In addition, the following method checks whether the address passed in the argument is registered as a contract interface or contract logic.

Since VersionLogic and VersionField described later contain the caller access control, please use them.

  • ContractNameService.isVersioncontract()

    function isVersionContract(address _sender, bytes32 _name) constant returns(bool) {
        if (Utils.isNull(_sender)) throw;
        for (uint i = 0; i < contracts[_name].length; i++) {
            if (contracts[_name][i].main == _sender) return true;
        }
        return false;
    }
    
  • ContractNameService.isVersionLogic()

    function isVersionLogic(address _sender, bytes32 _name) constant returns(bool) {
        if (Utils.isNull(_sender)) throw;
        for (uint i = 0; i < contracts[_name].length; i++) {
            if (contracts[_name][i].logic == _sender) return true;
        }
        return false;
    }
    

results matching ""

    No results matching ""