The UTXO as a Service (UaaS) monitors BSV Node Peer to Peer (P2P) messages and builds its own UTXO set that can be queried to obtain non-standard transactions.
This uses service implemented in Rust with a Python REST API web interface.
The two components read the same configuration file and share data using MySQL database and a shared data directory.
The diagram also shows the Docker containers that make up the service.

The service stores blocks and can return transactions from those blocks.
If you need transactions that are not in blocks but are in the mempool you will need to set up a Collection which
will capture all transactions that match a particular pattern.
For more details on setting up a Collection see the configuration documentation here.
This project uses the following Chain-Gang Rust library for processing peer to peer (P2P) messages: https://github.com/nchain-innovation/chain-gang
The docker compose starts the componets that make up the UaaS system in one command.
First build the images using the build.sh command.
$ ./build.shThen start the system
$ docker-compose up -dTo stop the system
$ docker-compose downThe service is developed in Rust.
The best way to install Rust is to use rustup, see https://www.rust-lang.org/tools/install
To build:
cd rust
cargo buildNote that this project requires the MySQL database running to run.
See the Database section below for details.
To run:
cd rust
cargo runIf the following message is seen in the output, this would mean that the service is unable to conect to the MySQL database.
thread 'main' panicked at 'Problem connecting to database. Check database is connected and configuration is correct.
: DriverError { Could not connect to address `localhost:3306': Cannot assign requested address (os error 99) }', src/uaas/logic.rs:52:14
The REST Web interface has been developed in Python.
To run this
cd python\src
./web.pyNote again that this is dependent on MySQL database.
This will provide a REST API with a Swagger interface at http://localhost:5010/docs
This service records data to a MySQL database which must be present for the service to run.
Database setup details can be found here.
Encapsulating the service in Docker removes the need to install the project dependencies on the host machine.
Only Docker is required to build and run the service and web interface.
Note that the MySQL docker image is still required.
To build the docker image associated with the service run the following comand in the project directory.
./build.shThis builds two Docker images:
uaas-servicefor the Rust serviceuaas-webfor the Python REST API If there is an out of diskspace error whilst building the images, use the following comand to free up diskspace:
docker system pruneAs there are two Docker images there are also two startup scripts:
run_service.sh- to start the Rust servicerun_web.sh- to start the Python REST API
The configuration of the service is set in data/uaasr.toml file.
This is read when the service starts up.
For more details about the configuration file see here.
The following directories exist in this project:
├── data
├── docs
│ └── diagrams
├── python
│ └── src
├── rust
│ └── src
└── rust-sv
These directories contain the following:
data- Configuration, data and logs used and created by the servicedocs- Project documentationdocs/diagrams- PlantUML diagrams and source in support of the documentationpython/src- Python REST web interface to UaaSrust/src- Service source code in Rust
The following diagram shows how the Rust UaaS processes individual transactions and blocks from peer nodes.

The point to note that as transactions (or tx) are received they are:
- the
txadded to themempooldatabase table - the
txinputoutpointsare removed from theUTXOtable - the
txoutputoutpointsare added to theUTXOtable
When blocks are received:
- the
txare removed from themempooland added to thetxstable - the
txinputoutpoints(if present) are removed from theUTXOtable - the
txoutputoutpointsare added/updated to theUTXOtable - the Block's
blockheaderis added to theBlockstable
Another point to note is that this means that blocks and transaction can be processed prior to the block tip being obtained.
The only constraint is that the blocks must be processed in order. This is achieved by ensuring that the prev_hash field of the block matches the hash of the last block processed, all other blocks are placed on a queue for later processing.
Project development details can be found here.
Project status notes can be found here.
This project includes two Docker images: uaas-web and uaas-service. These images are essential components of UTXO as a Service (UAAS). By publishing them to Docker Hub, they become accessible for use by other projects and applications within the ecosystem.
Both images can be built and published to Docker Hub using a single script.
To build and publish the images, run the following command:
./multi-build.sh
Requirements
-
Docker Buildx: The script requires Docker's Buildx extension to be set as the active builder. Ensure Buildx is properly installed and selected as the current Docker engine. For help, see Docker Buildx
-
Publishing Permissions: Only members of the
innovationteam within thenChainDocker Hub organisation are authorised to publish images with the appropriate tags. Ensure you are logged in with the necessary permissions before running the script, else this will fail.
To login to Docker Hub at the command line use:
docker login -u <name>
When prompted enter the password.
