npm init. You will definitely need modules from
ocoreand if you are going to send payments, you will also need
package.jsonshould list these dependencies:
npm installto fetch dependencies.
.envfile, 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 (
amountis payment amount in the smallest units. If the payment was successful, you get its
unitin the callback and can save it or watch further events on this unit.
my_transactions_became_stableevent handlers are to be invoked after any new transaction received to any of your wallet addresses and when this transactions become stable, respectively.
arrUnitsis an array of units (more accurately, unit hashes) that contained any transaction involving your addresses. The event
new_my_transactionsis triggered for outgoing transactions too, you should check if the new transaction credits one of the addresses you are expecting payments to.
mci_became_stablewhich is emitted each time a new main chain index (MCI) becomes stable:
bot-examplerepository 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/.gitand 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_addressis user's device address (not to be confused with payment addresses),
user_messageis their message.
command codetext to your bot.