Skip to main content
A TAPLE node is instantiated using the Node::build method, which requires configuration settings and a database manager.

Configuration Overview

TAPLE node configuration is divided into two main categories:
  • Network Settings - P2P network configuration
  • Node Settings - General node behavior and cryptographic settings

Network Configuration

Network settings control how the node connects to the TAPLE network.

NetworkSettings Structure

pub struct NetworkSettings {
    /// Multiaddr addresses to listen on
    pub listen_addr: Vec<ListenAddr>,
    /// List of bootstrap nodes to connect to
    pub known_nodes: Vec<String>,
    /// External addresses to advertise
    pub external_address: Vec<String>,
}

Listen Addresses

TAPLE supports three types of listen addresses: IP4 Address (default):
ListenAddr::IP4 {
    addr: Some(std::net::Ipv4Addr::new(0, 0, 0, 0)),
    port: Some(40040),
}
IP6 Address:
ListenAddr::IP6 {
    addr: Some(std::net::Ipv6Addr::LOCALHOST),
    port: Some(40040),
}
Memory Address (for testing):
ListenAddr::Memory { 
    port: Some(40040) 
}
The default port is 40040.

Known Nodes

Bootstrap nodes are specified using the libp2p Multiaddr format:
known_nodes: vec![
    "/ip4/172.17.0.2/tcp/40040/p2p/12D3KooWLXexpg81PjdjnrhmHUxN7U5EtfXJgr9cahei1SJ9Ub3B".to_string(),
    "/ip4/172.17.0.3/tcp/40040/p2p/12D3KooWRS3QVwqBtNp7rUCG4SF3nBrinQqJYC1N5qc1Wdr4jrze".to_string(),
]

Node Configuration

Node settings control the core behavior of the TAPLE node.

NodeSettings Structure

pub struct NodeSettings {
    /// Key derivator algorithm (Ed25519, Secp256k1)
    pub key_derivator: KeyDerivator,
    /// Secret key in hexadecimal format
    pub secret_key: String,
    /// Digest algorithm for identifiers
    pub digest_derivator: DigestDerivator,
    /// Percentage of network nodes to replicate to (0.0-1.0)
    pub replication_factor: f64,
    /// Timeout between protocol iterations (milliseconds)
    pub timeout: u32,
    /// Smart contracts directory path
    #[cfg(feature = "evaluation")]
    pub smartcontracts_directory: String,
}

Default Values

NodeSettings::default() = NodeSettings {
    key_derivator: KeyDerivator::Ed25519,
    secret_key: String::from(""),
    digest_derivator: DigestDerivator::Blake3_256,
    replication_factor: 0.25,  // 25% of nodes
    timeout: 3000,  // 3 seconds
    smartcontracts_directory: "./contracts".into(),
}

Building a Node

1

Generate or load a key pair

use taple_core::crypto::*;

// Generate a random key pair
let node_key_pair = crypto::KeyPair::Ed25519(
    Ed25519KeyPair::from_seed(&[])
);
2

Configure the settings

use taple_core::Settings;

let settings = {
    let mut settings = Settings::default();
    settings.node.secret_key = hex::encode(node_key_pair.secret_key_bytes());
    
    // Optional: customize network settings
    settings.network.listen_addr = vec![ListenAddr::IP4 {
        addr: Some(std::net::Ipv4Addr::new(0, 0, 0, 0)),
        port: Some(40040),
    }];
    
    // Optional: add known nodes
    settings.network.known_nodes = vec![
        "/ip4/172.17.0.2/tcp/40040/p2p/12D3KooWLXexpg81PjdjnrhmHUxN7U5EtfXJgr9cahei1SJ9Ub3B".to_string(),
    ];
    
    settings
};
3

Initialize the database manager

For testing, use the in-memory database:
use taple_core::MemoryManager;

let database = MemoryManager::new();
For production, implement the DatabaseManager trait with a persistent storage solution.
4

Build the node

use taple_core::Node;

let (mut node, api) = Node::build(settings, database)
    .expect("TAPLE node built");
The build method returns:
  • node - The node instance for receiving notifications
  • api - The API interface for interacting with the node

Node Lifecycle

Controller ID

When the node is built, it generates and logs a Controller ID:
Controller ID: EtbFWPL6eU_YE2JqRb6xVdmVH14e6C28aBZ_VuOFYxuQ
This identifier is derived from the node’s public key and is used throughout the TAPLE network.

Shutdown

Gracefully shutdown the node:
node.shutdown_gracefully().await;
Or bind to a shutdown signal:
node.bind_with_shutdown(async {
    tokio::signal::ctrl_c().await.unwrap();
});

Configuration Files

TAPLE Core uses the config crate, allowing configuration via:
  • TOML files
  • Environment variables
  • JSON files
  • Command-line arguments
Example TOML configuration:
[network]
listen_addr = ["/ip4/0.0.0.0/tcp/40040"]
knownnodes = ["/ip4/172.17.0.2/tcp/40040/p2p/12D3KooWLXexpg81PjdjnrhmHUxN7U5EtfXJgr9cahei1SJ9Ub3B"]
externaladdress = []

[node]
keyderivator = "Ed25519"
secretkey = "a9e2..." 
digestderivator = "Blake3_256"
replicationfactor = 0.25
timeout = 3000
smartcontracts_directory = "./contracts"

Next Steps

Learn how to use the node and API in Basic Usage.

Build docs developers (and LLMs) love