@babbage/tokenator
v0.2.37
Published
The ultimate tool for creating and transferring tokens
Downloads
93
Readme
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/tokenator
Example 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
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
Tokenator
Extendable class for interacting with a PeerServ
Parameters
obj
object? 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
messageBox
string
listenForLiveMessages
Start listening on your "public" message room Anyone can send you a message here
Parameters
obj
object all params given in an object
sendLiveMessage
Send a message over sockets, with a backup of messageBox delivery
Parameters
obj
object all params given in an object
sendMessage
Sends a message to a PeerServ recipient
Parameters
message
object The object containing the message params
Returns String status message
listMessages
Lists messages from PeerServ
Parameters
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
acknowledgeMessage
Acknowledges one or more messages as having been recieved ensuring deletion of the message(s)
Parameters
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
License
The license for the code in this repository is the Open BSV License.