Options
All
  • Public
  • Public/Protected
  • All
Menu
description

This class contains the implementation of the handshake contract which is used to discover handshake requests in the FOLIO dApp.

Use this class whenever you are interpreting an operation of handshake for your dApp. Also, an instance of this class is created using Factory.createFromJSON given a contract signature that matches: /:handshake$/ (ends with).

Parameters

Following inputs apply to the Handshake contract class:

Input Type Required? Description
dappIdentifier string Required The dApp identifier, e.g. "folio".
issuer string Required This field should contain the public key of the issuer of the handshake, i.e. the account that initiates the handshake operation.
recipient string Required This field should contain the public key of the recipient of the handshake, i.e. the account of the second participant in the handshake operation.
operation string Required The transaction hash of the confirmed AggregateComplete transaction that contains a handshake operation and encryption keys.



example

Using the Handshake contract class

// creating a reward contract
const contract: Handshake = new Handshake({
dappIdentifier: "folio",
issuer: "ISSUER_PUBLIC_KEY",
recipient: "RECIPIENT_PUBLIC_KEY",
operation: "HANDSHAKE_TRANSACTION_HASH"
});



Other links

HandshakeParameters | Contract | Factory

since

v1.0.0

Hierarchy

Index

Constructors

  • Construct a handshake contract. Note that some of the inputs are required.

    The handshake contract requires inputs including the dappIdentifier, the issuer account public key, the recipient account public key and an operation transaction hash. Refer to the above parameters description for more details.

    access

    public

    Parameters

    • inputs: HandshakeParameters

      The inputs that are used during execution ("arguments").

    • version: number = 1

      (Optional) The contract version number (defaults to 1).

    • parameters: NetworkParameters = ...

      (Optional) The network parameters ("connection").

    Returns Handshake

Properties

parameters: NetworkParameters = ...
version: number = 1

Accessors

  • This method should return an ObjectLiteral that consists of the body of the contract, e.g. in the Handshake contract the body contains a date, a scope and a purpose.

    In the handshake contract, we always include the level, scope and purpose fields.

    Note that by modifying the required fields of a contract's body, you must also update the version of the contract to prevent inconsistencies in operations.

    access

    public

    abstract

    Returns ObjectLiteral

    An object that consists of custom fields related to the scope of the contract.

  • get dApp(): string
  • This getter method transforms the provided dappIdentifier input into a slug. The characters set for valid slugs includes: lowercase alpha-numerical characters, underscores and hyphens. Additionally, multiple hyphens in a series are replaced for single hyphens.

    This method is used internally to determine a dapp identifier that is compliant to a strict characters set.

    access

    private

    Returns string

    A slugified dApp identifier as present on-chain.

  • This getter method prepares the contract header. The header consists of the contract signature and version of the contract.

    The contract header is always attached to contracts using the toJSON method.

    access

    public

    Returns ObjectLiteral

    An object that consists of the contract signature and version.

  • get identifier(): string
  • This method should return a string that is used as the identifier of the contract being executed.

    This identifier will be concatenated with the dApp identifier to form the contract signature.

    This method should return an identifier that is unique across one dApp, i.e. it is OK to re-define an handshake contract in a different dApp than FOLIO.

    access

    public

    abstract

    Returns string

    A contract identifier as present on-chain in the contract signature.

  • This getter method returns the contract payload as it is attached inside transfer transaction messages.

    This method is used internally to determine a contract payload that is used to produce JSON in toJSON.

    access

    public

    Returns ObjectLiteral

    A full contract payload (with "contract" and "version").

  • get signature(): string
  • This getter method returns the contract signature as it is attached inside contracts' JSON payloads.

    This method is used internally to determine a contract signature that is included in the contract header.

    access

    public

    Returns string

    A contract signature, e.g. "elevate:auth".

Methods

  • getMosaics(): Mosaic[]
  • This method should return an array of Mosaic instances as defined in @dhealth/sdk. The transaction assets consists of a set of assets that are attached to a transaction on dHealth Network.

    Note that the Handshake contract does not attach any mosaics to the transfer transaction.

    access

    protected

    Returns Mosaic[]

    An array of assets and amounts thereof that are attached to a transfer transaction.

  • Helper method that creates an Address instance out of transaction parameters. Parameters may include a recipientPublicKey or a recipientAddress. If both are provided, the recipientAddress takes precedence.

    Note that in the case of providing a `recipientPublicKey, this method uses the internal Contract.parameters to determine the network identifier.

    Parameters

    • parameters: TransactionParameters

      A configuration object that is passed to the creation process of the dHealth Network Transaction.

    Returns Address

    A dHealth Network Account Address from @dhealth/sdk.

  • toJSON(): string
  • This method creates a JSON payload using the contract header and the custom body fields, as defined in child classes.

    Note that the resulting string is attached as is to the transfer transaction on dHealth Network.

    access

    public

    Returns string

    A JSON payload that can be attached to transfer transactions.

  • This method should return a prepared Transaction object from @dhealth/sdk. This transaction will not be broadcast or signed yet and this method can be called without requiring an internet connection ("off-line").

    Note that by modifying the transaction that is created when executing a contract, you must also update the version of the contract to prevent inconsistencies in operations.

    access

    public

    abstract

    Parameters

    • parameters: TransactionParameters

      A configuration object that is passed to the creation process of the dHealth Network Transaction.

    Returns TransferTransaction

    A prepared (but unsigned) dHealth Network Transaction.

  • This method uses a Transaction child class from which it reads the contract JSON payload.

    Invalid JSON errors will trigger the InvalidContractError exception to be thrown.

    This method is used internally to transform a Transaction object into an ObjectLiteral by making sure that the JSON payload uses valid JSON formatting rules and lives inside either of: the transfer transaction message or the aggregate bundle's first transfer transaction's message.

    access

    protected

    throws

    {InvalidContractError} Given no contract JSON payload is found or given a contract JSON payload that contains invalid JSON and could not get parsed into a contract.

    Parameters

    • transaction: Transaction

      A transaction object that contains the full definition of the executed contract.

    Returns ObjectLiteral

    A parsed contract consists of an object of type ObjectLiteral.

Generated using TypeDoc