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.
npm i @babbage/tokenator
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()
Defines the structure of a PeerServ Message
Type: Object
messageId
Number identifies a particular messagebody
String the body of the message (may be a stringified object)sender
String the identityKey of the sendercreated_at
String message creation timestamp as a stringupdated_at
String message update timestamp as a string
Extendable class for interacting with a PeerServ
-
obj
object? All parameters are given in an object (optional, default{}
)
Establish an initial socket connection to a room The room ID is based on your identityKey and the messageBox
messageBox
string
Start listening on your "public" message room Anyone can send you a message here
-
obj
object all params given in an object
Send a message over sockets, with a backup of messageBox delivery
-
obj
object all params given in an object
Sends a message to a PeerServ recipient
-
message
object The object containing the message params
Returns String status message
Lists messages from PeerServ
-
obj
Object An object containing the messageBoxobj.messageBox
Array The name of the messageBox to list messages from
Returns Array<PeerServMessage> of matching messages returned from PeerServ
Acknowledges one or more messages as having been recieved ensuring deletion of the message(s)
-
obj
Object An object containing the messageIdsobj.messageIds
Array An array of Numbers indicating which message(s) to acknowledge
Returns Array of messages formatted according to the particular protocol in use
The license for the code in this repository is the Open BSV License.