bcevents
Sends and listens to events broadcasted on bitcoin transactions. Events can be used to trigger remote actions or send payloads to listeners.
Install
npm install bcevents datapay bsv
Get Started
var Emitter = var emitter = pkey: 'private key for tx fees' emitter // prints { ..., payload: 1234 }emitter // prints tx hash
Protocol
Everytime emit()
is called, a new transaction is broadcasted with the event and payload inside the OP_RETURN:
- OP_RETURN
- protocol_id
- event
- payload (optional)
The protocol Id should be set when creating emitters otherwise the events will be listened by any agent using the default protocol id.
emitter = protocol: 'my-unique-protocol-id'
Encryption
To Encrypt both event and payload on transactions, use the enkKey field. When set, transaction data will be encrypted and decrypted using AES.
var emitter = encKey: 'my-password'
To use a different encryption, both encrypt and decrypt function can be set:
var emitter =
Examples
Ping-Pong
// endless ping-pong between two agents// oracle.jsvar emitter = pkey: 'oracle pkey' protocol: 'pingpongtest' emitter // client.jsvar emitter = pkey: 'client pkey' protocol: 'pingpongtest' emitteremitter
Whitelisting
var whitelist = addr1 addr2 ... // addresses whitelist emitter