Contractless is a peer-to-peer Fair-Proof-of-Work blockchain with native multi-asset transactions, torrent-based block synchronization and deterministic orphan correction. This README contains the minimum information needed to build, configure and start a node.
For the protocol design, mining rules, balance-sheet model and orphan correction process, read the [Contractless whitepaper](https://contractless.community/contractless_whitepaper.pdf).
A public node needs to be reachable by other peers.
- Open the active RPC port in the local firewall.
- Forward the active RPC port through the router or host firewall when behind NAT.
- Set `IP` in `settings.ini` to the reachable public IP or reachable domain name for the node.
- Keep system time synchronized. Any reliable NTP/time server should work because Contractless only requires second-level timestamp agreement. A common default is `pool.ntp.org`.
- Keep PostgreSQL reachable locally by the node process.
Loopback and private addresses are useful for local testing, but they should not be announced by a public node.
That command will fail until mainnet is enabled for launch.
## PostgreSQL Setup
Contractless uses PostgreSQL for transaction lookup and mempool-style records. PostgreSQL only needs a database, user, password and permissions before the node starts. On startup, the node creates or migrates the required tables and indexes automatically. The node also uses local file and sled storage for chain state, wallets, balance sheets and torrents.
### Linux PostgreSQL CLI Tool
Build the release binaries, then run the installer as root so it can install PostgreSQL if needed and create the database, user, password and permissions:
```bash
sudo ./target/release/postgres_installer
```
After the tool completes, copy the printed PostgreSQL values into the active PostgreSQL section of `settings.ini`.
### Windows PostgreSQL CLI Tool
Open PowerShell as Administrator, copy the built installer into the install folder, then run it:
Manual PostgreSQL instructions should live in [docs/POSTGRES.md](src/branch/main/docs/POSTGRES.md). Until that file is fully written, use the CLI installer unless you already know how to create the database, user and permissions manually.
Relative paths in `settings.ini` are resolved relative to the location of that `settings.ini` file. The node scopes runtime data by active network internally, so testnet and mainnet paths do not collide when using the same base folders.
The main runtime folders are:
-`BLOCK_PATH`: saved block files
-`TORRENT_PATH`: torrent metadata and staged torrents
-`DB_PATH`: sled state
-`WALLET_PATH`: encrypted wallet files
-`BALANCE_SHEET`: balance sheet files
-`LOG_PATH`: runtime logs
### Linux Copy Instructions
Create the config folder and copy the sample settings file:
Create or restore a wallet before starting a public node, then make sure the wallet is registered and the wallet path/name in `settings.ini` matches the runtime wallet.
### Linux Startup
Start the testnet node:
```bash
contractless-testnet
```
Linux prompts for the wallet decryption key, then detaches into the background automatically.