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
uuid
for 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
uuid
has 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
uuid
is 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 build
yarn start
Create 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
stake
command KNS tokens - Use the
link
command to link your stake with your subnet ID - Use the
update-subnet
command to submit your subnet information - Use the
authorize
command 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
delegations
collection must have a unique index on theuser
field. - The
transactions
collection must have a unique composite index on theuser
,uuid
,subnet
andtype
fields. - The
users
collection must have a unique composite index onuser
,subnet
, andcurrency
fields.
This project uses:
- TypeScript
- ESLint for linting
- Prettier for consistent formatting
To lint the code:
yarn lint
To 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.