npm init
. You will definitely need modules from ocore
and if you are going to send payments, you will also need headless-obyte
. Your package.json
should list these dependencies:npm install
to fetch dependencies..env
file, which should contain just one line:node index.js
. You'll see initialization lines printed by ocore in console, which contain your wallet first address printed and an error saying that There are no funded addresses
. This is our failed attempt to issueChangeAddressAndSendPayment()
, as you don't have any bytes in your wallet yet.onReady function
), we send one byte to some address. First argument is an asset
, its the asset you are paying in (null
for bytes), amount
is payment amount in the smallest units. If the payment was successful, you get its unit
in the callback and can save it or watch further events on this unit.exports
of https://github.com/byteball/headless-obyte/blob/master/start.js.new_my_transactions
and my_transactions_became_stable
event handlers are to be invoked after any new transaction received to any of your wallet addresses and when this transactions become stable, respectively. arrUnits
is an array of units (more accurately, unit hashes) that contained any transaction involving your addresses. The event new_my_transactions
is triggered for outgoing transactions too, you should check if the new transaction credits one of the addresses you are expecting payments to.mci_became_stable
which is emitted each time a new main chain index (MCI) becomes stable:bot-example
repository as a starting point for your chat bot. You can also use the module from previous step, but it will require you to add some more config lines, so its better to git clone [email protected]:byteball/bot-example.git
, remove .git folder rm -fr bot-example/.git
and tweak some default configs there (remember to give a name to your bot, switch to light node, set up a pairing secret, etc.)byteball:
scheme, users will be able to open a chat with your bot by clicking your link (the link opens in their Obyte app and starts a chat):pairing_secret
, the second argument of the event handler. For example, you can have a one-time (non-permanent) pairing secret equal to session ID on your website; after the user clicks the pairing link and opens chat, you can link his chat session with his web session, see Authenticating users on websites.from_address
is user's device address (not to be confused with payment addresses), user_message
is their message.sendMessageToDevice
function in device
module:command code
text to your bot.