Skip to content

Commit 107f635

Browse files
authored
Update pallet docs (#131)
* push to repo * prettier * cleanup * cleanup prettier * cleanup prettier * cleanup prettier * cleanup prettier * simplify credits docs * fix: simplify * cleanup prettier * cleanup prettier
1 parent 6200a0a commit 107f635

File tree

13 files changed

+343
-17
lines changed

13 files changed

+343
-17
lines changed

components/EvmToSubstrateConverter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const AddressConverter = () => {
3737
try {
3838
const convertedAddress = evmToTangle(evmAddress);
3939
setTangleAddress(convertedAddress);
40-
} catch (error) {
40+
} catch {
4141
setTangleAddress("Invalid EVM address.");
4242
}
4343
};

components/Tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const Tabs: FC<{
1313
const { data, mutate } = useSWR(storageKey, (key) => {
1414
try {
1515
return JSON.parse(localStorage.getItem(key) ?? "");
16-
} catch (e) {
16+
} catch {
1717
return null;
1818
}
1919
});

pages/developers/precompiles/features/multi-asset-delegation.mdx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ Below are example usages for some core methods on the multi-asset delegation int
5959

6060
1. Expand the `deposit(uint256 assetId, address tokenAddress, uint256 amount, uint8 lockMultiplier)` section.
6161
2. Set `assetId` to `0` for ERC20 tokens, or provide another valid ID for other assets.
62-
3. Provide the ERC20 contract address in `tokenAddress` if `assetId` is `0`. If using a native asset ID, this may be ignored depending on your setup.
62+
3. Provide the ERC20 contract address in `tokenAddress` if `assetId` is `0`. For native assets, set this to the zero address.
6363
4. Enter the `amount` you wish to deposit (in your asset's smallest unit, e.g., Wei for WETH).
64-
5. Specify a `lockMultiplier` value if required by your delegation logic (`0` for no lock).
64+
5. Specify a `lockMultiplier` value for lock duration rewards (`0` for no lock, higher values for increased rewards).
6565
6. Click "transact" and confirm the MetaMask popup.
6666

6767
### 2. Schedule a Withdrawal
6868

6969
1. Expand `scheduleWithdraw(uint256 assetId, address tokenAddress, uint256 amount)`.
7070
2. Fill in `assetId` (`0` for ERC20), `tokenAddress` (if `assetId` is `0`), and `amount`.
7171
3. Click "transact" and approve the MetaMask transaction.
72-
4. The withdrawal is now scheduled; you can later execute or cancel it.
72+
4. The withdrawal enters an unbonding period; you can execute it after the period ends or cancel it anytime.
7373

7474
### 3. Execute a Scheduled Withdrawal
7575

@@ -87,8 +87,9 @@ Below are example usages for some core methods on the multi-asset delegation int
8787
### 5. Delegate to an Operator
8888

8989
1. Expand `delegate(bytes32 operator, uint256 assetId, address tokenAddress, uint256 amount, uint64[] memory blueprintSelection)`.
90-
2. Enter the operator (as a bytes32 account id), the asset ID, token address if assetId is `0` (ERC20), the amount to delegate, and any required blueprint parameters.
91-
3. Click "transact" to nominate that account as your operator with a specified stake.
90+
2. Enter the operator (as a bytes32 account ID), the asset ID, token address if assetId is `0` (ERC20), the amount to delegate.
91+
3. Provide `blueprintSelection` as an array of blueprint IDs the operator should participate in.
92+
4. Click "transact" to delegate your assets to the operator.
9293

9394
### 6. Schedule Unstake for Delegators
9495

@@ -112,8 +113,8 @@ Below are example usages for some core methods on the multi-asset delegation int
112113
### 9. Check Overall Balance
113114

114115
1. Expand `balanceOf(address who, uint256 assetId, address tokenAddress)`.
115-
2. Enter the address you want to inspect, assetId (0 for ERC20), and `tokenAddress` if needed.
116-
3. Click "call" to see the total amount of assets held (deposited + delegated).
116+
2. Enter the address you want to inspect, assetId (`0` for ERC20), and `tokenAddress` if needed.
117+
3. Click "call" to see the total amount of assets held (deposited but not yet delegated).
117118

118119
### 10. Check Delegated Balance
119120

@@ -123,6 +124,22 @@ Below are example usages for some core methods on the multi-asset delegation int
123124

124125
---
125126

127+
## Asset Types
128+
129+
- **Asset ID 0**: ERC20 tokens (requires token address)
130+
- **Asset ID 1+**: Native or custom assets configured in the runtime
131+
132+
## Lock Multipliers
133+
134+
The `lockMultiplier` parameter in the deposit function allows users to lock their assets for longer periods in exchange for increased rewards:
135+
136+
- `0`: No lock (standard delegation)
137+
- Higher values: Longer lock periods with proportionally higher reward multipliers
138+
139+
## Blueprint Selection
140+
141+
When delegating, the `blueprintSelection` parameter specifies which service blueprints the operator should run on your behalf. This enables targeted delegation to specific services or applications.
142+
126143
## More Information
127144

128145
For a complete list of methods and their parameters, refer to the Solidity interface above. This interface exposes all the critical multi-asset delegation functionality provided by Tangle's runtime, enabling you to manage deposits, schedule and execute withdrawals, delegate tokens, and unstake as needed—all through an Ethereum-compatible workflow. Make sure to handle asset IDs, token addresses, and amounts accurately to avoid transaction failures.

pages/developers/precompiles/overview.mdx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The precompiled contracts are categorized by address and based on the origin net
8484
| Schnorr-Ristretto255 | Verifies Schnorr signatures using the Ristretto255 curve. | `0x000000000000000000000000000000000000081f` |
8585
| Schnorr-Taproot | Verifies Schnorr signatures using the Taproot Scheme. | `0x0000000000000000000000000000000000000820` |
8686
| Bls12-381 | Performs operations on the BLS12-381 curve. | `0x0000000000000000000000000000000000000821` |
87-
| MultiAsset Delegation | Provides functions for managing multi-asset delegation pallet. | `0x0000000000000000000000000000000000000822` |
88-
| Services Pallet | Provides functions for managing services pallet. | `0x0000000000000000000000000000000000000823` |
89-
| Liqued Staking | Provides functions for managing liquid staking pallet. | `0x0000000000000000000000000000000000000824` |
87+
| Tangle LST | Provides functions for managing liquid staking pools. | `0x0000000000000000000000000000000000000809` |
88+
| MultiAsset Delegation | Provides functions for managing multi-asset delegation. | `0x0000000000000000000000000000000000000822` |
89+
| Credits | Provides functions for managing cloud credits system. | `0x0000000000000000000000000000000000000825` |
90+
| Services | Provides functions for managing service blueprints and instances. | `0x0000000000000000000000000000000000000900` |

pages/restake/_meta.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const meta: Meta = {
1515
},
1616
"restake-introduction": "Tangle Restaking",
1717
incentives: "Incentives",
18+
credits: "Tangle Credits",
1819
how_to_restake: "How to Restake on Tangle",
1920
restake_developers: "Developer Docs",
2021
"-- liquid staking": {

pages/restake/credits/_meta.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Meta } from "nextra";
2+
3+
const meta: Meta = {
4+
index: "Overview",
5+
claiming: "How to Claim Credits",
6+
precompile: "Credits Precompile",
7+
};
8+
9+
export default meta;

pages/restake/credits/claiming.mdx

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
title: How to Claim Credits
3+
description: Step-by-step guide to claiming your earned credits from the Cloud Credits pallet
4+
---
5+
6+
# How to Claim Credits
7+
8+
This guide walks you through the process of claiming your earned credits from TNT staking through the Cloud Credits pallet.
9+
10+
## Prerequisites
11+
12+
- **Active TNT Stake**: You must have TNT staked through Tangle's multi-asset delegation system
13+
- **Minimum Stake**: Your stake must meet the lowest tier threshold to earn credits
14+
- **Off-chain Account**: An identifier linking your claim to off-chain credit management
15+
16+
## Claiming via Polkadot.js Apps
17+
18+
### Step 1: Connect to Tangle Network
19+
20+
1. Go to [Polkadot.js Apps](https://polkadot.js.org/apps)
21+
2. Connect to the Tangle Network endpoint
22+
3. Import or connect your account with TNT stake
23+
24+
### Step 2: Navigate to Extrinsics
25+
26+
1. Go to **Developer****Extrinsics**
27+
2. Select your account from the dropdown
28+
3. Choose `cloudCredits` from the pallet list
29+
4. Select `claimCredits` from the call dropdown
30+
31+
### Step 3: Fill Parameters
32+
33+
**Amount to Claim (`amount_to_claim`):**
34+
35+
- Enter the number of credits you want to claim
36+
- Must not exceed your accrued amount within the claim window
37+
- Use the RPC query (see below) to check your maximum claimable amount
38+
39+
**Off-chain Account ID (`offchain_account_id`):**
40+
41+
- Your identifier for linking to off-chain credit systems
42+
- Maximum length is configurable (check pallet constants)
43+
- Keep this consistent across claims
44+
45+
![PolkadotJS Claim](/images/claim.png)
46+
47+
### Step 4: Submit Transaction
48+
49+
1. Click **Submit Transaction**
50+
2. Enter your password if prompted
51+
3. Confirm the transaction
52+
4. Monitor the transaction status in the **Network****Explorer**
53+
54+
## Alternative: Asset-Specific Claims
55+
56+
For claiming credits from specific asset stakes:
57+
58+
1. Choose `claimCreditsWithAsset` instead of `claimCredits`
59+
2. Add the **Asset ID** parameter for the specific asset
60+
3. The same amount and off-chain account ID rules apply
61+
62+
![PolkadotJS Claim](/images/claim-assets.png)
63+
64+
## Events and Monitoring
65+
66+
### CreditsClaimed Event
67+
68+
When you successfully claim:
69+
70+
```
71+
CreditsClaimed {
72+
who: Your_Account_ID,
73+
amount_claimed: Claimed_Amount,
74+
offchain_account_id: Your_Offchain_ID
75+
}
76+
```
77+
78+
## Related Documentation
79+
80+
- [Credits Overview](/restake/credits) - Understanding the Cloud Credits pallet
81+
- [Credits Precompile](/restake/credits/precompile) - Technical documentation for developers
82+
- [How to Restake](/restake/how_to_restake) - Guide to staking TNT tokens

pages/restake/credits/index.mdx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
title: Credits
3+
description: Earn free usage credits for AI tools by staking TNT tokens on Tangle.
4+
---
5+
6+
# Credits
7+
8+
## What Are Credits?
9+
10+
Credits are a way for re-stakers on Tangle to earn credits on [ai.tangle.tools](https://ai.tangle.tools). When you stake TNT tokens, you automatically earn credits that can be used for AI services like text generation, image creation, and other AI tools.
11+
12+
## How to Earn Credits
13+
14+
Stake TNT/LstTNT tokens on Tangle and you'll automatically start earning credits. The more TNT you stake, the more credits you earn over time. You don't need to do anything special - just stake your tokens and credits accumulate automatically.
15+
16+
## How to Use Your Credits
17+
18+
1. Stake TNT tokens on Tangle
19+
2. Visit [ai.tangle.tools](https://ai.tangle.tools)
20+
3. Claim your accumulated credits
21+
22+
### Earning Mechanism
23+
24+
Credits accumulate based on your staked TNT amount. Higher stake amounts earn credits at a higher rate.
25+
26+
### Credit Expiry
27+
28+
Credits have an expiry period to encourage regular usage rather than hoarding. On Tangle Mainnet, you can accumulate credits for up to one week from your last claim. After one week, your accumulated credits reset to zero and you start earning fresh credits again.
29+
30+
This system encourages users to actively claim and use their credits rather than letting them pile up indefinitely.
31+
32+
### Claiming Process
33+
34+
To claim credits, you submit a transaction with your GitHub account as the off-chain ID. The system calculates how many credits you've earned based on your stake, verifies this amount, and emits an event that credits the specified amount to your GitHub account on ai.tangle.tools.
35+
36+
## Next Steps
37+
38+
- **[How to Claim Credits](/restake/credits/claiming)** - Learn how to claim your earned credits
39+
- **[Credits Precompile](/restake/credits/precompile)** - Technical documentation for developers working with the credits system
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: Credits Precompile
3+
description: Solidity interface for interacting with the Tangle Credits system
4+
---
5+
6+
# Credits Precompile
7+
8+
The Credits precompile provides an Ethereum-compatible interface for interacting with the Tangle Credits system. This allows smart contracts and dApps to manage credits programmatically.
9+
10+
## Contract Address
11+
12+
- **Mainnet & Testnet**: `0x0000000000000000000000000000000000000825`
13+
14+
## Interface
15+
16+
```solidity
17+
// SPDX-License-Identifier: GPL-3.0-only
18+
pragma solidity >=0.8.3;
19+
20+
/// @dev The Credits contract's address.
21+
address constant CREDITS = 0x0000000000000000000000000000000000000825;
22+
23+
/// @dev The Credits contract's instance.
24+
Credits constant CREDITS_CONTRACT = Credits(CREDITS);
25+
26+
/// @author The Tangle Team
27+
/// @title Credits Pallet Interface
28+
/// @notice Interface for interacting with the Tangle Credits system
29+
/// @custom:address 0x0000000000000000000000000000000000000825
30+
interface Credits {
31+
/// @dev Burn TNT tokens to generate credits
32+
/// @param amount The amount of TNT to burn
33+
/// @return Success status (0 for success)
34+
function burn(uint256 amount) external returns (uint8);
35+
36+
/// @dev Claim accumulated credits
37+
/// @param amount The amount of credits to claim
38+
/// @param offchainAccountId The off-chain account identifier
39+
/// @return Success status (0 for success)
40+
function claimCredits(
41+
uint256 amount,
42+
bytes calldata offchainAccountId
43+
) external returns (uint8);
44+
45+
/// @dev Get the current credit emission rate for a staked amount
46+
/// @param stakedAmount The amount of TNT staked
47+
/// @return The credits earned per block
48+
function getCurrentRate(uint256 stakedAmount) external view returns (uint256);
49+
50+
/// @dev Calculate accrued credits for an account
51+
/// @param account The account to check
52+
/// @return The amount of claimable credits
53+
function calculateAccruedCredits(address account) external view returns (uint256);
54+
55+
/// @dev Get the current stake tier configuration
56+
/// @return thresholds Array of stake thresholds
57+
/// @return rates Array of emission rates per block
58+
function getStakeTiers() external view returns (
59+
uint256[] memory thresholds,
60+
uint256[] memory rates
61+
);
62+
63+
/// @dev Get stake tier for a specific asset
64+
/// @param assetId The asset identifier
65+
/// @return thresholds Array of stake thresholds
66+
/// @return rates Array of emission rates per block
67+
function getAssetStakeTiers(uint256 assetId) external view returns (
68+
uint256[] memory thresholds,
69+
uint256[] memory rates
70+
);
71+
72+
/// @dev Events
73+
event CreditsGrantedFromBurn(address indexed account, uint256 burned, uint256 credits);
74+
event CreditsClaimed(address indexed account, uint256 amount, bytes offchainAccountId);
75+
}
76+
```
77+
78+
### Claiming Credits
79+
80+
```solidity
81+
contract CreditClaimer {
82+
Credits constant credits = Credits(0x0000000000000000000000000000000000000825);
83+
84+
function claimMyCredits(uint256 amount, string memory accountId) external {
85+
// Convert string to bytes for off-chain account ID
86+
bytes memory offchainId = bytes(accountId);
87+
88+
// Claim the credits
89+
uint8 result = credits.claimCredits(amount, offchainId);
90+
require(result == 0, "Claim failed");
91+
}
92+
}
93+
```
94+
95+
## Related Documentation
96+
97+
- [Credits Overview](/restake/credits/overview)
98+
- [Claiming Credits](/restake/credits/claiming)
99+
- [Multi-Asset Delegation](/developers/precompiles/features/multi-asset-delegation)

pages/restake/incentives/how_rewards_work.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Restaking rewards in the Tangle Network are designed to incentivize both operato
1414
3. **Reward Vaults:** Asset Vaults to which restaked tokens are assigned for reward distribution.
1515
4. **Delegators:** Users who delegate their tokens to operators, sharing in the rewards generated by the operators' activities.
1616
5. **Operators:** Validators who restake their tokens and provide services, earning rewards through their participation in the restaking protocol.
17+
6. **Lock Duration Multipliers:** Enhanced rewards for longer lock periods (1.1x to 1.6x multipliers).
18+
7. **Service-Specific Rewards:** Rewards tied to specific service blueprints and instances.
1719

1820
## Whitelisting Blueprints for Rewards
1921

0 commit comments

Comments
 (0)