BIoT Wallet have internal applications. With the help of this API you can develop your own applications.
Example:
Copy const core = require ( 'biot-core' );
const eventBus = require ( 'ocore/event_bus' );
let timers = {};
let n = {};
( async () => {
await core .init ( 'test' );
eventBus .on ( 'paired' , (from_address) => {
core .sendTechMessageToDevice (from_address , {type : 'imapp' });
});
eventBus .on ( 'object' , async (from_address , object) => {
if ( object .app === 'BIoT' ) {
if ( object .type === 'hello' ) {
n[from_address] = 0 ;
core .sendTechMessageToDevice (from_address , {
type : 'render' , page : 'start' , form : [
{type : 'h2' , id : 'n' , title : 0 }
]
});
timers[from_address] = setInterval (() => {
n[from_address] ++ ;
core .sendTechMessageToDevice (from_address , {
type : 'update' , id : 'n' , value : {type : 'h2' , title : n[from_address] , id : 'n' }
});
} , 1000 );
} else if ( object .type === 'close' ) {
console .error ( 'close' , from_address);
clearInterval (timers[from_address]);
delete timers[from_address];
delete n[from_address];
}
}
});
})() .catch ( console .error); Using to display the html block <input>, using with title, id, required.
Example:
{type: 'input', title: 'Name', id: 'name', required: true}
f.type === 'address'
Creates a link, by clicking on which the address is going to be selected.
Example:
{type: 'address', required: true, title: 'Select wallet for address', id: 'address'}
f.type === 'blank_line'
Using to create a blank line by displaying the html block. <div><br/></div>
f.type === 'submit'
Using to create a button when clicking on which sends the completed data to the server.
Example:
{ type: 'render', page: 'index', form: [ {type: 'input', title: 'Name', id: 'name', required: true}, {type: 'input', title: 'Last Name', id: 'lname', required: true}, {type: 'input', title: 'Age', id: 'age', required: true}, {type: 'address', required: true, title: 'Select wallet for address', id: 'address'}, {type: 'blank_line'}, {type: 'submit', title: 'Send'} ] }
f.type === 'h2'
Using to display the html block <h2> </h2>, where “title” is what you want to display.
Example:
{type: 'h2', title: 'You attested'}
f.type === 'h3'
Using to display the html block <h2> </h2>, where “title” is what you want to display.
Example:
{type: 'h3', title: 'Scan RFID to start'}
f.type === 'text'
Using to display text, where “title” is what you want to display.
Example:
{type: 'text',title: (openChannels[from_address].myAmount - 1) + '/1000 bytes',id: 'balanceChannel'}
f.type === 'request'
Using for sending small data.
Example:
{type: 'request', title: 'Close channel', req: 'close_channel'}
f.type === 'list-menu'
Using for sending small data.
Example:
{type: 'list-menu', title: 'Switch on red light', req: 'switch_red'}
object.type === 'render'
Using to render the page. Required along with page and form.
Where “page” is the name of the page and “form” is what needs to be displayed.
Example:
{ type: 'render', page: 'attested', form: [ {type: 'h2', title: 'You attested'} ] }
object.type === 'addProfile'
Using to save profile data:
my_address - address of attestor,
your_address - your addres,
unit - profile publication unit,
profile - profile object
Example:
https://github.com/BIoTws/attestation-app/blob/master/index.js arrow-up-right
{ type: 'addProfile', my_address: res.address, your_address: object.response.address, unit: res.objJoint.unit.unit, profile: res.src_profile }
object.type === 'alert'
Using to display an error through alert. Where “message” is the error text.
Example:
{type: 'alert', message: 'Error'}
object.type === 'update'
Using to update existing data.
id - id of replacement data
value - which element will be inserted there with the corresponding parameters
Example:
{ type: 'update', id: 'balanceChannel', value: { type: 'text', title: (channel.myAmount - 1) + '/1000 bytes', id: 'balanceChannel' } }