getData: Get DATA with ACL

Reading data with ACL (access control).

API Cloud Block Chain

Processing Sequence

GetData SomeContract

  • 1 AltExecCnsContract #getData

    We call AltExecCnsContract from the client logic.

    When calling, parameters are passed including the "name", "function name", "parameter", etc. of the contract to be ultimately called.

  • 1.1 API GET data

    The client module provided by this service signs the hash value derived from all the arguments and does a GET request to the API.

  • 1.1.1 ContractNameService#getLatestcontract

    The API server queries the CNS for the address of the latest version of the contract.

  • 1.1.2 SomeContract#someMethod

    The API server calls the contract as instructed by the end user.
    Here, someMethod should be implemented by the service provider so that it returns the object ID list to be downloaded.

  • 1.1.3 canRead

    Within the API server, check using the data on Ethereum that the end user (address) has read permission for the target data.

  • 1.1.4 getData

    Retrieves the hash value of the target data from Ethereum, retrieves the corresponding data from the data store, and returns it to the end user.

Implementation by the service provider

  • ClientSide

    • AltExecCnsContract#getData

      var contract = new AltExecCnsContract(account, '__CNS_ADDRESS__');
      contract.getData('__PASSWORD__', 'SomeContract', 'someMethod', ['p0', 1, 'p2'], abi, function(err, res) {
          if (err) console.error(err);
          else {
  • Contract

    • SomeContract

      The contracts to be implemented are invoked with parameters as specified by the end user, but we implement so that we return the object ID group to be acquired as the return value.

      contract SomeContract is VersionContract {
          function SomeContract(ContractNameService _cns) VersionContract(_cns, "SomeContract") {}
          function someMethod(
                  bytes32 _p0, 
                  uint _p1, 
                  bytes32 _p2) constant returns (bytes32) {
              return "objectId";


  • msg.sender

    Calling the constant function is done with the signature of the account for payment.

    "msg.sender" is an account designated to each service provider for payment and is not the end user.

    getData receives a sign from end user, recovers the address and checks whether the address is a reader of DataObject. When the address is a reader, end user get the data. Data which is gotten by getData has been written in not BlockChain but external DB, therefore, we can set the access control for those data.

  • Simplified implementation

    In the example above, we are implementing logic directly in SomeContract to illustrate the point, but in fact it is necessary to implement it in the form of basic contract configuration.

For details on how to implement the original Contract, refer to the following sources.

results matching ""

    No results matching ""