Installation and usage of the platform

REST API: working with confidential smart contracts

https://img.shields.io/badge/auth-required-orange.svg

The confidential-contracts methods group is provided to handle confidential smart contracts.

POST /confidential-contracts/call

The POST /confidential-contracts/call REST method is used to transfer confidential smart contracts data outside the blockchain.

Important

You can only call the POST /confidential-contracts/call method when you have an oAuth token with the ConfidentialContractUser role or a special api-key.

The POST /confidential-contracts/call method is not available for contracts without confidentiality support (isConfidential = false).

The POST /confidential-contracts/call method returns an error if there are less than three nodes with the contract-validator role among the members of the authorization group (policy).

The following data is passed in the method request:

  • broadcast – the flag that marks the need to broadcast the generated CallContract transaction; the field defaults to true; the false value is used to form an atomic container;

  • commitmentVerification – the flag that marks the necessity of input data commitment reconciliation and the need for the user to provide a key for commitment generation; the field defaults to false; if false is set, the node generates the key randomly and calculates the commitment; if commitmentVerification is set to true and the user has not passed commitment or commitmentKey, or has passed an incorrectly generated commitment value or an incorrect commitmentKey, the method returns an error;

  • sender – the confidential smart contract data sender address;

  • contractId – the confidential smart contract identifier;

  • contractVersion – the confidential smart contract version;

  • params – when working with CallContract transaction, the field holds input data of the confidential smart contract, represented as an array of objects; data is entered using the following fields:

    • key – the parameter key;

    • type – the parameter data type;

    • value– the parameter value.

  • timestamp – the Unix Timestamp (in milliseconds), marking the time of the smart contract call;

  • atomicBadge – the flag that marks if the transaction can be included in an atomic transaction;

  • fee – the transaction fee;

  • feeAssetId – the fee token identifier;

  • commitment – the commitment;

  • commitmentKey – the commitment key.

The POST /confidential-contracts/call method takes all the data needed to send a CallContract version 6 transaction, then sends it, and returns a protobuf that includes the CallContract transaction version 6 and the confidential input data to start the confidential smart contract (ConfidentialInput) in the response.

Response example:

Note

The POST /confidential-contracts/call REST method is similar to the ConfidentialCall gRPC method.

GET ​/confidential-contracts/{contractId}

The method returns the selected keys values from the confidential smart contract state to the members of the corresponding policy (authorization group).

Important

You can only call the GET ​/confidential-contracts/{contractId} method if you are a member of the corresponding policy and have an oAuth token with the ConfidentialContractUser role or a special api-key.

The following data is passed in the GET ​/confidential-contracts/{contractId} method request:

  • contractId – the confidential smart contract identifier;

  • limit – the limit of number of data blocks to be obtained;

  • offset – the number of data blocks to be missed in the method response;

  • matches – an optional parameter to compose a regular expression that filters the keys.

Response example for policy members:

Response example for the addresses that are not policy members:

Note

There are similar methods for conventional smart contracts: GET /contracts/{contractId} and POST /contracts/{contractId}.

GET /confidential-contracts/tx/{executable-tx-id}

The method returns the transaction of writing the confidential smart contract execution result to its state (105.ExecutedContract version 4), the confidential input data to run the contract (ConfidentialInput) and the confidential contract execution results (confidentialOutput) to the participants of the corresponding policy (authorization group).

In turn, 105.ExecutedContract transaction contains all the fields of 103. CreateContract, 104. CallContract, 107. UpdateContract transactions of the smart contract.

Important

You can only call the GET /confidential-contracts/tx/{executable-tx-id} method if you are a member of the corresponding policy and have an oAuth token with the ConfidentialContractUser role or a special api-key.

Response example for policy members:

Response example for the addresses that are not policy members:

Note

There is a similar method for conventional smart contracts: GET /contracts/executed-tx-for/{id}.