call : Constant Methods

Contract constant methods.

API Cloud 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__');'__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";


  • 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.

    Data which is gotten by call has been written in BlockChain and is accessible by anyone, therefore, we cannot set the access control for those data.

    (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 ""