UNPKG

@tanglemesh/compute.js

Version:

A simple package to do computing tasks for publishing to the tangle (eg. attatchToTangle)

55 lines (36 loc) 2.2 kB
# compute.js A simple package to do computing tasks for publishing to the tangle (eg. attatchToTangle) This package provides you some computing features to outsource some computing intensive tasks like the `attatchToTangle` method many libraries of [iotaledger](https://github.com/iotaledger/) needs. For more details have a look on [https://tangle-mesh.io](https://tangle-mesh.io). ## Installation This is an npm-package and you can add it to your project by using npm with: npm install @tangleMesh/compute.js ## Usage import Compute from '@tanglemesh/compute.js'; import { ApiAuthentificator } from "@tanglemesh/api-client.js"; import { composeAPI } from "@iota/core"; //Set credentials for using the tangleMesh:api const apiIdentifier = "api-identifier", apiSecret = "api-secret"; const apiAuth = new ApiAuthentificator (apiIdentifier, apiSecret); //Create the `compute` object for doing computation tasks const compute = new Compute (apiAuth); // Initialize the iota compose api and use our compute-method(s) const iota = composeAPI ({ provider: 'https://nodes.thetangle.org:443', compute: compute.attatchToTangle ("channel-id"), }); ## Authorization / API key In order to authorize your requests, you need to create an API key and secret at [https://tangle-mesh.io](https://tangle-mesh.io). The generated values can then be simply passed to the methods listed below. ## Methods ### attatchToTangle This method can be used to overwrite the default `attatchToTangle` method from the [iotaledger](https://github.com/iotaledger/) packages. compute.attatchToTangle (channelId) **Parameters:** - channelId `string` - the channel id you want to pay your request with (the costs per request will be listed on [our website](https://tangle-mesh.io)) ## Examples For more examples just have a look on the [/examples](/examples) directory. Run an example with the command: node examples/send-transaction.example.js ## Contact / Support For requests or questions simply create an issue on [our repository](https://github.com/tangleMesh/compute.js) or [contact us](https://tangle-mesh.io/contact) with our form.