0.20.0 • Published 1 year ago

rooot-browser-lib v0.20.0

Weekly downloads
22
License
BSD-2-Clause-Pate...
Repository
github
Last release
1 year ago

rooot-browser-lib

GitHub tag (latest by date) npm GitHub last commit GitHub issues NPM

This library holds the common modules used by the Rooot system in TypeScript. It's specially suited for websites interacting with the blockchain.

Usage

npm i rooot-browser-lib

NB: The library is still under development, so ask us for installation guidelines.

Examples
import {
  AccountsRestClient, GatewayRestClient, MetadataRestClient, TermsRestClient, TransactionRestClient,
  buildOblivionTransaction, createOblivionTransaction, Vectors
} from 'rooot-browser-lib'

// Get all account information
const accountsRestClient = AccountsRestClient('http://localhost:3014')
accountsRestClient.getAccount(yourCredentials).then(account => {
  // Use its info, eg. list its vectors
  console.log(Vectors(account.vectors).list())
})

// Ask for the metadata
const metadataRestClient = MetadataRestClient('http://localhost:3013')
metadataRestClient.getMetadata().then(metadata => {
  // Use them
  console.log(metadata.lastBlockId, metadata.timestamp)
})

// Get a transaction from a depositary's gateway
const gatewayRestClient = GatewayRestClient('http://localhost:3030')
gatewayRestClient.getTransaction('1234567890abcdef[...]')
  .then(transaction => {
    // Do sth with it
    console.log(transaction)
  })
  .catch(err => {
    // Handle it
    console.error(err)
  })

// Know the latest terms of a smart contract
const termsRestClient = TermsRestClient('http://localhost:3004')
termsRestClient.getTerms(publicKey)
  .then(terms => {
    // Read them
    console.log(terms.status, terms.channel, terms.end, terms.maxUse)
  })

// Post an oblivion transaction
const transactionRestClient = TransactionRestClient('http://localhost:3003')
const oblivionTx = await transactionRestClient.getMetadata()
  .then(([metadata, beneficiary]) => buildBaseOblivion(optinTx, optoutTx.transactionId, metadata, emitter, beneficiary)
    .then(createOblivionTransaction)
  )
transactionRestClient.sendOblivion(oblivionTx)

// Get the IDs of the 10 last blocks
const gatewayRestClient = GatewayRestClient('http://localhost:3030')
gatewayRestClient.last10Blocks()
  .then(blockIds => {
    // Do sth with them
    console.log(blockIds.includes(transaction.lastBlockId))
  })

Dependencies

To run the tests, you would need to install live-server:

npm i -g live-server

License

The use of the Rooot libraries and executables are subject to fees for commercial purpose and to the respect of the BSD-2-Clause-Patent license. Please contact us to get further information.

0.20.0

1 year ago

0.19.1

2 years ago

0.19.0

2 years ago

0.18.0

2 years ago

0.17.1

3 years ago

0.16.3

3 years ago

0.17.0

3 years ago

0.16.2

3 years ago

0.16.1

3 years ago

0.16.0

3 years ago

0.15.1

3 years ago

0.15.0

3 years ago

0.14.0

3 years ago

0.13.12

3 years ago

0.13.11

3 years ago

0.13.10

3 years ago

0.13.9

3 years ago

0.13.8

3 years ago

0.13.7

3 years ago

0.13.6

3 years ago

0.13.5

3 years ago

0.13.4

3 years ago

0.13.3

4 years ago

0.13.1

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.11.5

4 years ago

0.11.4

4 years ago

0.11.3

4 years ago