Skip to content

Examples

yaaccount edited this page Oct 16, 2019 · 12 revisions

NOTES:

There is a typescript project directly in this wiki repository with all the example sources - you can check it out and inspect:

  • git clone https://github.com/proximax-storage/tsjs-xpx-chain-sdk.wiki
    • see folder files/demo/src/demo

(those are referenced from other examples through Network class)

  • Get generationHash from block 1 (class NetworkProperties)
    • you need it as a mandatory parameter for every transaction signing
  • Wait for a transaction to be confirmed (method announceAndWaitForConfirmation)
  • Put all the http api endpoint classes into a single wrapper (class ApiEndpoint)
  • Generates new Keypair.
  • Generates a Keypair from a private key.
  • Generate Account struct.
  • Generate address from a public key.
  • Generate address from a private key.

Types of requests

  • Get AccountInfo for an account.
  • Get AccountsInfo for different accounts.
  • Get confirmed transactions information.
  • Get incoming transactions information.
  • Get outgoing transactions information.
  • Get unconfirmed transactions information.
  • Get aggregate bonded transactions information.
  • Get multisig account information.
  • Get multisig account graph information.
  • Get transaction information of transactionId or transactionHash.
  • Get transaction information for a given set of transactionId or transactionHash.
  • Get transaction status of transactionId or transactionHash.
  • Get an array of transaction statuses for a given set of transactionId or transactionHash.
  • Get mosaic information.
  • Get information for a set of mosaics.
  • Get readable names for a set of mosaics.
  • Get an array of MosaicInfo from mosaics created under provided namespace.
  • Get namespace information.
  • Get namespaces an account owns.
  • Get readable names for a set of namespaces.
  • Get an array of NamespaceInfo for a given set of addresses.
  • Get BlockInfo for a given block height.
  • Get transactions from a block.
  • Get the current height of the chain.
  • Get the current score of the chain.
  • Get the storage information.
  • Get an array of BlockInfo for a given block height and limit.
  • Get the current network type of the chain.

Announces a transaction

  • Create a transfer transaction
  • Create a root namespace
  • Create a sub namespace
  • Create a mosaic definition transaction
  • Create a mosaic supply change transaction
  • Create a modify multisig account transaction
  • Aggregate complete transaction

  • Aggregate bonded transaction

  • Aggregate cosignature transaction

  • Lock funds transaction

  • Scenario:
    • Seed account sends funds to both Alice and Bob in single aggregate complete transaction
    • Alice prepares and signs aggregate bonded transaction containing two inner transactions - one alice-to-bob and one bob-to-alice
    • Alice prepares and announces lock funds transactions for the above prepared aggregate bonded transaction
    • Alice announces the above prepared aggregate bonded transaction
    • Bob cosigns the aggregate bonded transaction from Alice and announces aggregate cosignature transaction
    • finally, the aggregate bonded transaction gets confirmed
  • Create a secret lock transaction
  • Create a secret proof transaction
  • Subscribe a block channel
  • Subscribe a confirmedAdded channel
  • Subscribe a unconfirmedAdded channel
  • Subscribe a unconfirmedRemoved channel
  • Subscribe a partialAdded channel
  • Subscribe a partialRemoved channel
  • Subscribe a cosignature channel
  • Subscribe a status channel
Clone this wiki locally