@servrox/ng-iota
v0.0.2
Published
This package is a wrapper for the iota.js library. Currently, only access to the indexed data payload messages is supported.
Downloads
3
Readme
ng-iota
This package is a wrapper for the iota.js library. Currently, only access to the indexed data payload messages is supported.
The library uses the iota mainnet (chrysalis).
The default chrysalis node is set to https://chrysalis-nodes.iota.org.
It can be changed by providing a custom configuration object in the module.ts file:
providers: [
{
provide: IotaServiceConfiguration,
useValue: {
apiEndpoint: 'https://your-custom-endpoint.org',
}
}
]
Following methods are supported:
constructor(
private iotaService: NgIotaService
) {
const msg: Message = {data: "data message"};
// creates a new message under the provided index
this.iotaService.sendIndexedData("test", JSON.stringify(msg)).subscribe(console.log);
// returns all message IDs for the provided index
this.iotaService.readIndexedData("test").subscribe(console.log);
// read all messages for the provided index
this.iotaService.readAllIndexedMessages("test").subscribe(console.log);
// read all messages for the provided index and parse the to the provided object
this.iotaService.readAllIndexedMessagesData<Message>("test").subscribe(console.log);
// read the message having the provided ID
this.iotaService.readMessage("iotaxxxxxxxxxxxxxxxx").subscribe(console.log);
}