Constructs a contract object. This constructor accepts inputs,
a version field and network parameters in parameters.
As noted in ContractParameters, the dappIdentifier
is obligatory
and must be present in the inputs. Please, note that this identifier
must be unique for the dApp you are building or otherwise, inconsistencies
may occur while the backend runtime is processing operations.
The inputs that are used during execution ("arguments").
(Optional) The contract version number (defaults to 1
).
(Optional) The network parameters ("connection").
This method should return an ObjectLiteral that consists of
the body of the contract, e.g. in the Auth contract
the body contains a challenge.
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.
An object that consists of custom fields related to the scope of the contract.
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.
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.
An object that consists of the contract signature and version.
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 earn
contract in a different dApp than elevate.
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.
A full contract payload (with "contract" and "version").
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.
A contract signature, e.g. "elevate:auth".
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.
A configuration object that is passed to the creation process of the dHealth Network Transaction.
A dHealth Network Account Address from @dhealth/sdk
.
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.
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.
A configuration object that is passed to the creation process of the dHealth Network Transaction.
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.
A transaction object that contains the full definition of the executed contract.
A parsed contract consists of an object
of type ObjectLiteral.
Generated using TypeDoc
The contract class serves as a base for defining digital contracts that are executed on dHealth Network. These are currently always included in transfer transactions as a JSON message and are versioned individually using a
version
field.Parameters
Following inputs apply to the Auth contract class:
dappIdentifier
string
Extending the
Contract
classOther links
Factory
v0.3.0