This repository implements the Admin Subnet Plugin for the Timeleap Network, as specified in TEP-6. The admin subnet acts as a decentralized ledger for fee tracking, user balance management, and signature-based billing verification across all subnets.
This plugin exposes standardized functions over Timeleap RPC for economic coordination and billing:
Adds funds to a user's balance in a specified currency.
schema Credit {
uuid byte8
amount uint64
currency string8(encoding = "ascii")
user byteN(length = 32)
subnet byteN(length = 32)
proof Signature
}- Requires a unique
uuidfor each credit request. - Signed by the subnet to prevent spoofing.
Deducts usage fees from a user's balance.
schema Debit {
uuid byte8
amount uint64
currency string8(encoding = "ascii")
user Signature
subnet byteN(length = 32)
proof Signature
}- Prevents overdraft or double spending.
- Fails if
uuidhas been seen before.
Reverses a previously submitted Credit.
schema Refund {
uuid byte8
amount uint64
currency string8(encoding = "ascii")
user byteN(length = 32)
subnet byteN(length = 32)
proof Signature
}- Can only be called by the original subnet.
- Fails if
uuidis not found in historical records.
Manage signing delegates for a subnet.
schema Authorize {
user byteN(length = 32)
subnet byteN(length = 32)
proof Signature
}
schema UnAuthorize {
user byteN(length = 32)
subnet byteN(length = 32)
proof Signature
}- Allows distributed signing across multiple trusted operators.
- Prevents unauthorized access to accounting APIs.
Standard Ed25519 signature schema.
schema Signature {
signer byteN(length = 32)
signature byteN(length = 64)
}- Used for authenticating all schema requests.
- Ensures requests are tamper-proof and cryptographically verifiable.
yarn buildyarn startCreate a .env file in the project root with the following values:
SUBNET_PRIVATE_KEY= # Private key used to sign admin responses
TIMELEAP_APP_ID= # Admin subnet App ID
MONGODB_URI= # MongoDB connection string for balance and log storage
ADMIN_SUBNET_PORT= # Subnet server port to listen to
# CLI
ADMIN_CLIENT_PRIVATE_KEY= # Private key to use for communicating with the admin subnet
ADMIN_BROKER_URI= # Admin subnet broker URI
ADMIN_BROKER_PUBLIC_KEY= # Admin subnet broker public key
EVM_PRIVATE_KEY= # EVM private key for staking & linking
EVM_RPC_ADDRESS # EVM JSON-RPC address (optional)
To install the tl-admin CLI, run:
npm i -g @timeleap/admin
The following commands are available for communicating with the Admin subnet:
credit: Credit a user's balanceupdate-subnet: Update subnet informationauthorize: Add a delegate to a subnetunauthorize: Remove a delegate from a subnetstake: Stake KNS tokensunstake: Unstake KNS tokenslink: Link a subnet to a staking address
To register a subnet, the following steps are required:
- Use the
stakecommand KNS tokens - Use the
linkcommand to link your stake with your subnet ID - Use the
update-subnetcommand to submit your subnet information - Use the
authorizecommand to authorize each one of your subnet server public keys to communicate with the Admin subnet on your behalf
You need the following indexes in MongoDB:
- The
delegationscollection must have a unique index on theuserfield. - The
transactionscollection must have a unique composite index on theuser,uuid,subnetandtypefields. - The
userscollection must have a unique composite index onuser,subnet, andcurrencyfields.
This project uses:
- TypeScript
- ESLint for linting
- Prettier for consistent formatting
To lint the code:
yarn lintTo auto-format:
yarn prettier© 2025 Timeleap SA. All rights reserved. Usage governed by the Timeleap Plugin Agreement.
This plugin enforces billing consistency, enables dispute resolution, and ensures privacy-preserving fee tracking across all Timeleap subnets. For detailed economic logic, see TEP-6.