Obyte developer resources
GitHubObyte.jsObyte.org
  • Quick Start
  • Configuration
  • Tutorials for newcomers
    • Setting up headless wallet
    • Ping-pong paymets
    • Logging into website
    • Weather oracle
    • Bet on weather bot
  • Payments and transactions
    • Textcoins
    • Sending data to DAG
  • Contracts
    • Smart contracts
    • Smart contract language reference
    • Prosaic contracts
    • Contracts with arbitration
  • Autonomous Agents
    • Getting started guide
    • Oscript language reference
  • Issuing assets on Obyte
  • Attestation profiles / KYC
  • Address signing/verification
  • URI protocol
  • Events list
  • Websocket API
    • Request
    • JustSaying
  • Obyte for merchants
    • Payments gateway
    • Cashback API
  • JSON-RPC
    • Exposing RPC interface
    • Running RPC service
  • Libraries and Scripts
Powered by GitBook
On this page
  • Wallet is ready (only headless wallet)
  • Start database update
  • End of database update
  • Connection to the hub via ws is established
  • Connection to the hub is established and an error is possible
  • Connected to ws
  • Not a fatal error
  • Unit validation status
  • New joint
  • Main chain index has become stable
  • New unstable transactions
  • Stable transactions
  • Bad transactions
  • First history received
  • Changes with addresses leading to possible new transactions
  • New unstable unit
  • New private payment
  • Stable unit
  • Syncing is idle
  • Catching up done
  • Catching up started
  • Catchup next hash tree
  • New direct private chains
  • Unhandled private payments left
  • Version of the connected user
  • New wallet version available
  • Received the project number for notifications on the phone
  • Client logged in
  • Message from the hub
  • Message for light client
  • Exchange rates are updated
  • Message received by hub
  • Notifications are enabled
  • Notifications are disabled
  • Create new wallet
  • Wallet created and signed
  • Wallet was rejected by the other side
  • Wallet has been confirmed by the other party
  • Created new address
  • Created new address
  • Unit saved
  • Attempt to pair us with another correspondent
  • Pairing was successful
  • Pairing was successful using pairing secret
  • The paired device has been removed
  • History update started
  • History update finished
  • A new message string type message has been received
  • A new message object type message has been received
  • Change in permission to store message history
  • Created a new shared address
  • Signing request
  • Signed event
  • Refuse to sign
  • Confirmed on another device
  • All private payments are processed
  • All private payments are processed in a unit
  • Event for custom Request
  • Event for custom JustSaying
  • Database is read and ready to work (only Cordova)
  • Error sending message via ws

Was this helpful?

Export as PDF

Events list

Event bus provides a way to subscribe to events from any of the services running.

const eventBus = require('ocore/event_bus.js');

Wallet is ready (only headless wallet)

Headless wallet is needed for bots that hold private keys and can send transactions. This event is emitted when passphrase has been entered by bot admin and single wallet is loaded. Before that event, bot outputs device address, device pubkey and pairing key.

eventBus.on('headless_wallet_ready', () => {

});

Start database update

This event is emitted when bot executes series database queries to upgrade the database to new version.

eventBus.on('started_db_upgrade', () => {

});

End of database update

This event is emitted when bot finishes database upgrade.

eventBus.on('finished_db_upgrade', () => {

});

Connection to the hub via ws is established

eventBus.on('connected', () => {

});

Connection to the hub is established and an error is possible

The url parameter is protocol + domain + path (for example: wss://obyte.org/bb).

eventBus.on('open-' + url, (error) => {

});

Connected to ws

eventBus.on('connected_to_source', (new_ws) => {

});

Not a fatal error

eventBus.on('nonfatal_error', (msg, Error) => {

});

Unit validation status

eventBus.on("validated-" + unit, (bValid) => {

});

New joint

eventBus.on('new_joint', (objJoint) => {

});

Main chain index has become stable

eventBus.on('mci_became_stable', (mci) => {

});

New unstable transactions

eventBus.on('new_my_transactions', (arrNewUnits) => {

});

Stable transactions

eventBus.on('my_transactions_became_stable', (arrUnits) => {

});

Bad transactions

eventBus.on('sequence_became_bad', (arrUniqueUnits) => {

});

First history received

eventBus.on('first_history_received', () => {

});

Changes with addresses leading to possible new transactions

eventBus.on('maybe_new_transactions', () => {

});

New unstable unit

eventBus.on("new_my_unit-" + unit, (objJoint) => {

});

New private payment

eventBus.on("received_payment", (payer_device_address, assocAmountsByAsset, asset, message_counter, bToSharedAddress) => {

});

Stable unit

eventBus.on('my_stable-' + unit , () => {

});

Syncing is idle

eventBus.on('sync_idle' , () => {

});

Catching up done

eventBus.on('catching_up_done' , () => {

});

Catching up started

eventBus.on('catching_up_started' , () => {

});

Catchup next hash tree

eventBus.on('catchup_next_hash_tree' , () => {

});

New direct private chains

eventBus.on('new_direct_private_chains' , (arrChains) => {

});

Unhandled private payments left

eventBus.on('unhandled_private_payments_left' , (rowsLength) => {

});

Version of the connected user

eventBus.on('peer_version', (ws, body) => {

});

New wallet version available

This event is emitted when Hub sends message about new wallet version.

eventBus.on('new_version', (ws, body) => {

});

Received the project number for notifications on the phone

eventBus.on('receivedPushProjectNumber', (ws, body) => {

});

Client logged in

eventBus.on('client_logged_in', (ws) => {

});

Message from the hub

eventBus.on("message_from_hub", (ws, subject, body) => {

});

Message for light client

eventBus.on("message_for_light", (ws, subject, body) => {

});

Exchange rates are updated

This event is emitted when wallet updated rates that they got from Hub.

const network = require('ocore/network.js');
eventBus.on("rates_updated", () => {
    console.log(JSON.stringify(network.exchangeRates, null, 2));
});

Message received by hub

eventBus.on('peer_sent_new_message', (ws, objDeviceMessage) => {

});

Notifications are enabled

eventBus.on("enableNotification", (device_address, params) => {

});

Notifications are disabled

eventBus.on("disableNotification", (device_address, params) => {

});

Create new wallet

eventBus.on("create_new_wallet", (walletId, wallet_definition_template, arrDeviceAddresses, wallet_name, other_cosigners, is_single_address) => {

});

Wallet created and signed

eventBus.on('wallet_completed', (walletId) => {

});

Wallet was rejected by the other side

eventBus.on('wallet_declined', (wallet, rejector_device_address) => {

});

Wallet has been confirmed by the other party

eventBus.on('wallet_approved', (wallet, device_address) => {

});

Created new address

eventBus.on('new_wallet_address', (address) => {

});

Created new address

eventBus.on("new_address-" + address, () => {

});

Unit saved

eventBus.on('saved_unit-' + unit, (objJoint) => {

});

Attempt to pair us with another correspondent

eventBus.on("pairing_attempt", (from_address, pairing_secret) => {
    if (pairing_secret == "SOME_SECRET") {
        eventBus.emit("paired", from_address, pairing_secret);
    }
});

Pairing was successful

This event is emitted on successful pairing (also when user removed and re-added the bot).

eventBus.on("paired", (from_address, pairing_secret) => {
    let device = require('ocore/device.js');
    // say hi to anyone who pair with bot
    device.sendMessageToDevice(from_address, 'text', 'Hi!');
});

Pairing was successful using pairing secret

eventBus.on('paired_by_secret-' + body, (from_address) => {

});

The paired device has been removed

eventBus.on("removed_paired_device", (from_address) => {

});

History update started

eventBus.on('refresh_light_started', () => {

});

History update finished

eventBus.on('refresh_light_done', () => {

});

A new message string type message has been received

This event is emitted when text message is received by bot.

eventBus.on("text", (from_address, body, message_counter) => {
    let device = require('ocore/device.js');
    // echo back the same message
    device.sendMessageToDevice(from_address, 'text', 'ECHO: '+ body);
});

A new message object type message has been received

This event is emitted when object message is received by bot.

eventBus.on("object", (from_address, body, message_counter) => {
    let device = require('ocore/device.js');
    // echo back the same object back
    device.sendMessageToDevice(from_address, 'object', body);
});

Change in permission to store message history

eventBus.on("chat_recording_pref", (from_address, body, message_counter) => {

});

Created a new shared address

eventBus.on("create_new_shared_address", (address_definition_template, assocMemberDeviceAddressesBySigningPaths) => {

});

Signing request

eventBus.on("signing_request", (objAddress, address, objUnit, assocPrivatePayloads, from_address, signing_path) => {

});

Signed event

eventBus.on("signature-" + device_address + "-" + address + "-" + signing_path + "-" + buf_to_sign.toString("base64"), (sig) => {

});

Refuse to sign

eventBus.on('refused_to_sign', (device_address) => {

});

Confirmed on another device

eventBus.on('confirm_on_other_devices', () => {

});

All private payments are processed

eventBus.on('all_private_payments_handled', (from_address) => {

});

All private payments are processed in a unit

eventBus.on('all_private_payments_handled-' + first_chain_unit, () => {

});

Event for custom Request

const network = require('ocore/network.js');

eventBus.on('custom_request', function(ws, params, tag) {
    var response = 'put response here';
    return network.sendResponse(ws, tag, response);
}

Event for custom JustSaying

eventBus.on('custom_justsaying', function(ws, content) {

};

Database is read and ready to work (only Cordova)

eventEmitter.once('ready', () => {
   console.log("db is now ready");
});

Error sending message via ws

ws.on('error', (error) => {

});
PreviousURI protocolNextWebsocket API

Last updated 3 years ago

Was this helpful?

This event is emitted when there is a pairing attempt, this enables bot to decide with the code if the pairing code is valid or not. If you would like to accept any pairing code then .

You can add your own communication protocol on top of the Obyte one. See Request example .

You can add your own communication protocol on top of the Obyte one. See JustSaying example .

there
there is easier solution
there