UBots overview


What is an UBot?

In short, UBot is a program written in modern JavaScript language (ECMA-262+ – so obviously it is fully Turing-complete, and doesn’t require you to learn a whole new language and architecture if you happen to know JavaScript), integrated in a special type of the Universa smart contract, signed and registered by the Universa network, so its code can not be tampered. The program can do virtually anything a regular program can do, not limited to the typical sandbox-limited dApp capabilities. Primarily, UBots are intended to perform any client-side processing for the Universa smart contracts. An UBot, for example, can execute periodic checks, communicate with any Internet service/API, itself provide an HTTP API and even run web sites, communicate to other ubots, create and change state of smart contracts, and do many other activities.

Generally, an UBot can provide:

  • functional interface: methods that could be called from clients using UMI-style interface from uniclient, libraries, or directly, using UMI-like protocol.
  • time-based events, also periodic.
  • networking I/O (for example, UBot can expose itself as HTTP service).

The UBots have some unique features provided by the tight integration with the main Universa network:

  • shared cloud storage. A smart contract can store contract-specific data, that will shortly be available on any UBot server, without collisions and race conditions.

  • consensus-based results. Any method could be marked as requiring consensus of some number of “ubot workers”. Any results and shared storage changes will therefore executed in parallel by many ubot servers, and could be rejected unless the required consensus is found. In this scenario, finding a consensus assumes that the required number of servers/workers arrived to the same result.

  • special shared data streams allowing parallelly executing instances to accumulate results. This approach, for example, allows ubots to generate secure distributed random number sequences, perform parallel calculations and so on.

  • special Universa-specific features, permissions and roles representing consensus of UBot worker instances. For example, it is possible to put some UTN tokens to the disposal of the ubot but require consensus of 30+ instances to perform any changes on it (e.g. to perform payments). In other words, the consensus of ubot instances can sign universa contracts, and some Universa contracts can require such a signature to be present.

How does it work?

The number of UBot servers is expected to be much more than the number of Nodes, as UBots usually perform slow and asynchronous operations (including waiting for network operations/IO, running calculations and much more). UBot servers run ubots and take a fee (directly in UTN!) for that; the amount of the fee depends on multiple factors, such as how long the UBot runs, how much shared storage is used and modified, and some other factors of this kind. Unlike the Universa network, an UBot server only gets paid for ubots it runs itself.

The UBot network is self-configured and backed by the Universa Mainnet, which accumulates information about currenly available UBot servers. Similarly to the Mainnet, the UBot network is 1-tier (all the nodes are equal) too, it self-configures as new servers join the network, existing servers shut down and get back online. The Ubot network randomly spreads ubots execution over the available servers, to balance the load and improve the response time.

Users can request the ubot execution on any specific ubot server they wish (if they really wish to run it on a specific server rather than the random-selected one), but most likely the execution will require consensus; in this case the initial ubot server will randomly select some other ubot servers to perform the requested operations. Also, the internal requirements can even explicitly prohibit launching some UBot on a non-random UBot server.

Also, the network requests and time events are executed on random UBot server using special load balancing algorithms backed by the Universa network.

Possible use cases and scenarios

Trading bot

Periodically checks rates on stock exchanges using the network interface and stock exchange APIs. Depending on it, it automatically trades tokens available in the portfolio. To get safe access to the token assets, it uses the consensual permission. Can also access external components like dedicated personal botserver that has access to private data to use external wallets and trading accounts to protect their credentials.

Store

Could be implemented as web service or a web site. All operation except the purchase could be performed fast without requiring any consensus, so the catalog, search, basket, preparing the order could be as fast as with a regular website; while any purchase could completely be made inside the ubot using Universa payments, or calling external payment and delivery providers (which could also be implemented as ubots).

Checkpoint

Uses a network-connected camera (with face-recognition software), QR-code (or similar visual codes) reader, NFC-reader or contract reader (for example, USB socket to use USB thumb drive as a pass) to check and redeem ticket contract and operate some physical turnstile or barrier.

Games with prizes

Ubot is capable to run turn-based games and provide fair and trustworthy prize awarging logic. Board games, card games, turn-based online strategies fit perfectly well into ubot capabilities. For real-time virtual world games, ubots still can be used to implement trusted game economics, transactions, contests and awards. And don’t forget the “cryptokitten”-style games, their (typically rather primitive) game logic can be implemented as easy as a school project.

Lottery

Could be implemented with very high level of trust by using the distributely generated random sequence to select a winner that excludes any fraud possibility. See below for secure decentralized network-generated random numbers.

Sweepstakes

Ubots can accept bets on any events, that could be programmatically checked using the network interfaces/APIs (do you want to bet on the outcome of the FIFA match of F1 race? or even if whether it will be raining tomorrow? Just find a service providing this information through the public API!) The consensus-based processing protects users from possible fraud.

Web applications and services

Could be easiliy implemented as ubots and then deployed with no pain in the ubot network. Easy to develop (modern JavaScript assumed), easy to deploy, payment only for actual load, the network automatically will use as many ubot servers as the application load requires. Of course, any static assets (pictures, CSS scripts) should be served separately for performance and cost reasons.

The personal wallet with web interface

Safely stores all the assets encrypted in the shared cloud storage, in user-encrypted form. Never lose any data anymore: sort of an improved and decentralized Crypto Cloud. Could also permit periodic payments, auto-accept and process incoming payments and so on. Also, could be used as a heavily protected/secure notebook, diary and file storage. Such an encrypted storage is planned to be much cheaper than SLOT1 store in the Universa Mainnet.

Chat bots for Universa chat service

UBots will have simple and convenient access to the Universa chat (Unichat) service.

Booking resources and tickets

Step ahead for ticket reservation. Using smart contracts for initial ticket pool guarantees no overbooking can ever happen; and there is no need in separate registration (confirmation) step like in the airports. The ubot could easily generate, sell, exchange and refund tickets making them immediately available for sale.

Surveillance and evidence collection

The ubot can collect information and safely store it, having it always approved by the Universa network. It is rather hard to remove any information that was ever inserted in the shared storage, and just impossible to tamper.

Voting and elections

Extremely easy to implement with Universa smart contracts as votes, and even using some KYC service to authenticate person in offline.

Shares, shareholders, meetings and so on

Could also be implemented using ubots with ease. Can even provide the web interfaces open new page in business automation and enterprise management as SaaS.

Smart home, city, organization

Collecting data from resource conusmption meters, consumtion planning and forecasting, buying resources. Everything from electricity and water to raw materials and components.

Distributed computations

Could be made exceptionally easy with the ubot network (think: AWS Lambda over Universa network, paid with UTNs!). Also, ubots will have “idle priority”: low-performance and cheap execution mode to handle the background processes.

Distributed random sequences (DRNG – decentralized random number generator)

Many ubots (running together) form a long pseudo-random (or random) sequence, where each ubot instance add its part of entropy and checks that it was actually used in the final random number. Special two-pass algorithm (already designed, TBA) prevents any possibility of fraud, even if any ubot server owners have an interest in some particular results of DRNG (e.g. it is used for a lottery) – they still won’t be able to tweak their input to the DRNG to affect the final result.

Distributed sample: image recognition

Suppose there is a camera that takes shots in real time and we want to detect in real time whether there are people from a very long list. Say, we want to distinguish hotel guests from visitors in the hotel elevator for security reasons. We can order each instance of ubots to check some few faces from a list, and run as many instances as we need in parallel getting real-time recognition.