Repository navigation
Custom Pallets
TKS includes four custom pallets that extend the Substrate SDK functionality.
Location: pallets/pallet-adaptive-gas/
Automatically scales the block gas limit based on real-time network utilization. This eliminates the need for manual parameter tuning and allows the chain to handle traffic bursts while staying lean during quiet periods.
Each block, the pallet measures the gas consumed relative to the current gas limit. If utilization is consistently high, the gas limit increases. If consistently low, it decreases. The algorithm is similar to EIP-1559's base fee adjustment but applied to the gas limit rather than price.
New Gas Limit = Current Gas Limit × (1 + adjustment_factor × utilization_delta)
| Parameter | Description | Default |
|---|---|---|
MinGasLimit |
Minimum allowed gas limit | ~1,500 tx equivalent |
MaxGasLimit |
Maximum allowed gas limit | ~80,000 tx equivalent |
AdjustmentFactor |
Speed of adjustment (per block) | 1/8 |
TargetUtilization |
Target fill ratio | 50% |
| Item | Type | Description |
|---|---|---|
CurrentGasLimit |
u64 |
Current block gas limit |
None — the gas limit adjusts automatically via the on_finalize hook.
Location: pallets/pallet-hyperswarm-anchor/
Allows decentralized applications to anchor their HyperSwarm DHT discovery keys to Layer-1 blockchain finality.
HyperSwarm is a P2P networking protocol used by Holepunch (the Hypercore Protocol ecosystem). Applications announce themselves on the DHT using a 32-byte public key. Other peers discover them by looking up this key. Anchoring this key on-chain provides:
- Tamper-proof registration — the key is stored at Layer-1 finality
- Censorship resistance — no central registrar can remove it
- Cross-chain verifiability — any chain that trusts TKS can verify the key
Register or update a HyperSwarm key for the calling account.
pallet-hyperswarm-anchor → anchor(key: 0xdeadbeef...)
Remove the calling account's anchored key.
| Item | Type | Description |
|---|---|---|
Anchors |
Map AccountId20 → [u8; 32]
|
Account → HyperSwarm key |
| Event | Description |
|---|---|
KeyAnchored(who, key) |
Key registered or updated |
KeyRevoked(who) |
Key removed |
Location: pallets/pallet-name-registry/
Provides free (zero-deposit) human-readable on-chain names such as alice.tks. Names are registered, transferred, and resolved entirely on-chain.
- No deposit — Unlike ENS or similar registries, TKS names require no deposit bond. This maximizes accessibility.
- First-come, first-served — Names are allocated to the first account that registers them.
- Transferable — Names can be transferred to another account.
- Substrate-native — Resolved on the Substrate side, not via EVM smart contracts (though EVM contracts can query names via precompiles).
Names are UTF-8 strings up to 64 bytes. The TLD .tks is implicit in the context of this pallet.
Register a name for the calling account. Fails if the name is already taken.
Transfer ownership of a registered name.
Release a registered name. Makes it available for re-registration.
| Item | Type | Description |
|---|---|---|
Names |
Map Vec<u8> → AccountId20
|
Name → owner |
OwnedNames |
Map AccountId20 → Vec<Vec<u8>>
|
Owner → names |
| Event | Description |
|---|---|
NameRegistered(name, owner) |
New name registered |
NameTransferred(name, from, to) |
Name ownership transferred |
NameDeregistered(name) |
Name released |
Location: pallets/pallet-shard-registry/
Provides coordination infrastructure for TKS shards — logical sub-chains or processing units that can be registered, tracked, and verified at Layer-1.
- Register a new shard with its genesis configuration hash
- Track which validators are assigned to which shard
- Coordinate cross-shard state roots for bridge verification
Register a new shard with its configuration hash.
Remove a shard registration (sudo-gated).
| Item | Type | Description |
|---|---|---|
Shards |
Map u32 → ShardInfo
|
Shard ID → registration data |
ShardCount |
u32 |
Total registered shards |
If you want to extend TKS with a new pallet:
- Create
pallets/pallet-your-pallet/ - Add
pallet-your-pallet = { path = "../pallets/pallet-your-pallet", default-features = false }toruntime/Cargo.toml - Implement
frame_support::pallet!macro with your storage, events, errors, and calls - Add
YourPallet: pallet_your_pallettoconstruct_runtime!inruntime/src/lib.rs - Implement the required
Configtrait
See the Substrate documentation for full guidance.