@babbage/tokenator v0.2.37
tokenator
Overview
Tokenator is a versatile and powerful tool that allows developers to easily create and transfer tokens peer-to-peer on the MetaNet.
The base-level class provides basic functionality such as sending, receiving, and deleting messages, while derived classes can be used to build specialized tokens for various applications. Examples of these derived classes include PaymentTokenator, EmailTokenator, PushDropTokenator, and ScribeTokenator.
With Tokenator, developers can take advantage of the power of the BSV blockchain, the simple messageBox architecture of PeerServ, privacy and mutual authentication with Authrite, and monetization with PacketPay to create cutting-edge decentralized applications.
Installation
npm i @babbage/tokenatorExample Usage
const Tokenator = require('@babbage/tokenator')
const johnSmith = '022600d2ef37d123fdcac7d25d7a464ada7acd3fb65a0daf85412140ee20884311'
const init = async () => {
// Create a new instance of the PushDropTokenator class
// Configure the parameters according to the protocol being used
const tokenator = new Tokenator({
peerServHost: 'https://staging-peerserv.babbage.systems'
})
// Send a generic message using Babbage
await tokenator.sendMessage({
recipient: johnSmith,
messageBox: 'example_inbox',
body: 'This is an example message!'
})
// John can now list messages in his messageBox on PeerServ
const messages = await tokenator.listMessages({
messageBox: 'example_inbox'
})
console.log(messages[0].body) // --> 'This is an example message!'
// Acknowledge that the messages have been received and can be deleted.
await tokenator.acknowledgeMessage({
messageIds: messages.map(x => x.messageId)
})
}
init()API
Table of Contents
PeerServMessage
Defines the structure of a PeerServ Message
Type: Object
Properties
messageIdNumber identifies a particular messagebodyString the body of the message (may be a stringified object)senderString the identityKey of the sendercreated_atString message creation timestamp as a stringupdated_atString message update timestamp as a string
Tokenator
Extendable class for interacting with a PeerServ
Parameters
objobject? All parameters are given in an object (optional, default{})
initializeConnection
Establish an initial socket connection to a room The room ID is based on your identityKey and the messageBox
Parameters
messageBoxstring
listenForLiveMessages
Start listening on your "public" message room Anyone can send you a message here
Parameters
objobject all params given in an object
sendLiveMessage
Send a message over sockets, with a backup of messageBox delivery
Parameters
objobject all params given in an object
sendMessage
Sends a message to a PeerServ recipient
Parameters
messageobject The object containing the message params
Returns String status message
listMessages
Lists messages from PeerServ
Parameters
objObject An object containing the messageBoxobj.messageBoxArray The name of the messageBox to list messages from
Returns Array<PeerServMessage> of matching messages returned from PeerServ
acknowledgeMessage
Acknowledges one or more messages as having been recieved ensuring deletion of the message(s)
Parameters
objObject An object containing the messageIdsobj.messageIdsArray An array of Numbers indicating which message(s) to acknowledge
Returns Array of messages formatted according to the particular protocol in use
License
The license for the code in this repository is the Open BSV License.
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago