computerthat contains a sub-object
Dband a sub-object
Wallet. In this section we explain the functions of the
Computerclass and we explain the
Walletclass in the following sections.
new()method creates new smart objects. It has two parameters, a class and a list of arguments. The arguments can be basic data types or smart objects.
new()method returns a smart object generated from the class and the arguments. It broadcasts a transaction that records the creation of the smart object. The smart object has the methods and properties defined in the class, and four extra properties:
_id: the location where the object is deployed. The id remains fixed throughout the lifecycle of the object.
_rev: the location where the object is currently stored. Initially
_revare identical. When a method of the smart object is called its new state is stored at a new location which is stored in the
_owners: an array containing string encoded public keys. A function can only be called on a smart object if it was created by a computer instance that contains a private key corresponding to a public keys in the list of owners.
_amount: a number encoding the number of satoshis stored in the smart object.
_revare read-only but the properties
_amountcan be assigned in constructor and function calls.
sync()method returns the smart object stored at a given revision.
a2will be distinct objects with identical values.
getRevs()method returns an array containing the latest revisions owned by a given public key. The public keys are string encoded. If no parameter is passed to
getRevs()the public key of the
computerobject is used.
getLatestRev()method inputs an id and returns the latest revision of the smart object with that id. If no smart object with that id exists an error is thrown.
revwill be equal to
a1is a smart object.
Dbclass is to create an object of the
Computerclass and to access its property
put()method inputs an array of JSON objects and stores them in a transaction. Each element of the array is stored in a separate output. The method returns the array of locations of the outputs created.
get()method returns the JSON objects stored at a given array of locations.
update()method has two parameters: a list of locations and a list of JSON objects. It broadcasts a transaction that spends the locations and that has one output for each JSON object. The output script of each output is the concatenation of a multisig script and a OP_PUSH that adds the JSON followed by OP_DROP.
Walletinstance by creating a
Computerinstance and accessing the nested
getBalance()method returns the current balance in satoshi.
send()method sends an amount of satoshi to an address.