call : Constant Methods

Contract constant methods.

API

Z.com Cloud Block Chain / ConoHa Block Chain

Processing Sequence

The invocation flow of calling constant methods is as follows.

Call SomeContract

  • 1 AltExecCnsContract#call

    Invoke AltExecCnsContract#call from within the client logic.

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

  • 1.1 API GET

    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 requested by the end user.

Implementation by the service provider

  • ClientSide

    • AltExecCnsContract#call

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

    • SomeContract

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

Note

  • msg.sender

    Calling the constant function is done with the account for payment by the API.

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

    In the Ethereum blockchain, the data is basically open, and in the service (beta version) we consider that user access control is unnecessary regarding reading, and the end user's signature check is done within the API server.

    (However, there is a possibility that this functionality may be changed in the shift to production.)

  • Simplified implementation

    In the example above, we implement logic directly in SomeContract for clarity, but in fact it is necessary to implement it separately as in basic contract configuration.

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

results matching ""

    No results matching ""