Skip to content

Commit 30dd398

Browse files
committed
simplify credits docs
1 parent cee89bd commit 30dd398

File tree

3 files changed

+18
-243
lines changed

3 files changed

+18
-243
lines changed

pages/restake/credits/claiming.mdx

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,6 @@ description: Step-by-step guide to claiming your earned credits from the Cloud C
77

88
This guide walks you through the process of claiming your earned credits from TNT staking through the Cloud Credits pallet.
99

10-
## Understanding the System
11-
12-
### How Credit Claiming Works
13-
14-
The Cloud Credits pallet tracks **potential credits** earned through TNT staking. When you claim:
15-
16-
1. **Calculation**: The pallet calculates credits accrued within the claim window
17-
2. **Verification**: It verifies your requested amount doesn't exceed the calculated maximum
18-
3. **Event Emission**: A `CreditsClaimed` event is emitted for off-chain processing
19-
4. **No On-Chain Balance**: No actual tokens are transferred - this is purely event-based
20-
21-
### Claim Window System
22-
23-
- Credits accrue within a configurable time window (`ClaimWindowBlocks`)
24-
- Only credits earned within the current window can be claimed
25-
- Regular claiming prevents losing potential credits from window expiration
26-
2710
## Prerequisites
2811

2912
- **Active TNT Stake**: You must have TNT staked through Tangle's multi-asset delegation system
@@ -78,38 +61,6 @@ For claiming credits from specific asset stakes:
7861

7962
![PolkadotJS Claim](/images/claim-assets.png)
8063

81-
## Understanding Stake Tiers
82-
83-
Credit emission rates depend on your stake tier:
84-
85-
### Tier System
86-
87-
- Higher stakes unlock higher emission rates per block
88-
- Tiers are configured during genesis with thresholds and rates
89-
- The pallet uses the highest tier your stake qualifies for
90-
91-
### Example Calculation
92-
93-
```
94-
If you stake 50,000 TNT and qualify for Tier 2 (1.0 credits/block):
95-
- Claim window: 7200 blocks (24 hours)
96-
- Last claim: 3600 blocks ago
97-
- Claimable credits: 3600 blocks × 1.0 = 3,600 credits
98-
```
99-
100-
## Checking Accrued Credits
101-
102-
### Using RPC Queries
103-
104-
Before claiming, check your accrued amount:
105-
106-
1. Go to **Developer****RPC calls**
107-
2. Select the appropriate RPC method
108-
3. Enter your account ID
109-
4. Optionally specify a block number
110-
111-
This shows your maximum claimable amount without submitting a transaction.
112-
11364
## Events and Monitoring
11465

11566
### CreditsClaimed Event
@@ -124,50 +75,6 @@ CreditsClaimed {
12475
}
12576
```
12677

127-
### CreditsGrantedFromBurn Event
128-
129-
When you burn TNT:
130-
131-
```
132-
CreditsGrantedFromBurn {
133-
who: Your_Account_ID,
134-
tnt_burned: Burned_Amount,
135-
credits_granted: Calculated_Credits
136-
}
137-
```
138-
139-
## Troubleshooting
140-
141-
### Common Errors
142-
143-
**`ClaimAmountExceedsWindowAllowance`**
144-
145-
- You're trying to claim more than your accrued amount
146-
- Check your actual accrued credits using RPC queries
147-
- Reduce the claim amount to within the calculated limit
148-
149-
**`InvalidClaimId`**
150-
151-
- Your off-chain account ID exceeds the maximum length
152-
- Check the `MaxOffchainAccountIdLength` constant
153-
- Use a shorter identifier
154-
155-
**`NoValidTier`**
156-
157-
- Your stake is below the minimum tier threshold
158-
- Increase your TNT stake to qualify for credit accrual
159-
- Check current tier configuration
160-
161-
**`AmountZero`**
162-
163-
- You entered zero for the amount
164-
- Specify a positive amount to claim or burn
165-
166-
**`InsufficientTntBalance`**
167-
168-
- You don't have enough TNT to burn
169-
- Check your free balance before burning
170-
17178
## Related Documentation
17279

17380
- [Credits Overview](/restake/credits) - Understanding the Cloud Credits pallet

pages/restake/credits/index.mdx

Lines changed: 18 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,37 @@
11
---
2-
title: Cloud Credits Pallet
3-
description: Learn about Tangle's cloud credits system that tracks potential usage credits earned through staking and burning TNT tokens.
2+
title: Credits
3+
description: Earn free usage credits for AI tools by staking TNT tokens on Tangle.
44
---
55

6-
# Cloud Credits Pallet
6+
# Credits
77

8-
## Overview
8+
## What Are Credits?
99

10-
The Cloud Credits pallet provides an on-chain mechanism for tracking **potential usage credits** earned through staking TNT or burning TNT. It is designed to work with an off-chain system that listens to events to manage actual user credit balances.
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.
1111

12-
The pallet integrates with Tangle's multi-asset delegation system to reward users who stake TNT tokens by tracking passively accrued potential credits within a defined time window.
12+
## How to Earn Credits
1313

14-
## Key Features
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.
1515

16-
### Staking-Based Potential Credit Accrual
16+
## How to Use Your Credits
1717

18-
- Tracks potential credits earned based on TNT stake via `MultiAssetDelegationInfo`
19-
- Accrual is **capped** to a configurable time window (`ClaimWindowBlocks`)
20-
- Users do not accrue additional potential credits for periods longer than this window without claiming
18+
1. Stake TNT tokens on Tangle
19+
2. Visit [ai.tangle.tools](https://ai.tangle.tools)
20+
3. Claim your accumulated credits
2121

22-
### Stake Tier Configuration
22+
### Earning Mechanism
2323

24-
- Credit emission rates based on stake size are defined via `StakeTier` structs
25-
- Configured during genesis and stored on-chain
26-
- Higher stake amounts unlock higher emission rates per block
24+
Credits accumulate based on your staked TNT amount. Higher stake amounts earn credits at a higher rate.
2725

28-
### TNT Burning Event
26+
### Credit Expiry
2927

30-
- Burning TNT emits an event (`CreditsGrantedFromBurn`) indicating potential credits granted
31-
- Credits are available for immediate off-chain use
32-
- Burned tokens are permanently removed from circulation or sent to a configured recipient
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.
3329

34-
### Credit Claiming Event
30+
This system encourages users to actively claim and use their credits rather than letting them pile up indefinitely.
3531

36-
- Users initiate a claim on-chain with an off-chain account ID
37-
- The pallet calculates potential credits accrued within the `ClaimWindowBlocks` ending at the current block
38-
- Verifies the requested amount against calculated value and emits a `CreditsClaimed` event
39-
- **No on-chain balance is stored or deducted** - this is purely for event emission
32+
### Claiming Process
4033

41-
### Window Cap
42-
43-
- Inactivity beyond the `ClaimWindowBlocks` results in no further potential credit accrual for that past period
44-
- Encourages regular claiming to maximize credit earning
45-
46-
## How It Works
47-
48-
### Earning Credits
49-
50-
**Through Staking (Passive Accrual):**
51-
52-
1. Stake TNT tokens through Tangle's multi-asset delegation system
53-
2. Credits automatically accrue based on your staked amount and the configured tier rates
54-
3. Accrual is calculated per block within the claim window
55-
4. Higher stake amounts may qualify for higher tier emission rates
56-
57-
### Claiming Credits
58-
59-
1. Call the `claim_credits` extrinsic with:
60-
- Amount to claim (must not exceed calculated accrued amount)
61-
- Off-chain account ID for credit association
62-
2. The pallet verifies the claim amount against accrued potential credits
63-
3. Emits a `CreditsClaimed` event for off-chain processing
64-
4. Updates the reward tracking block to prevent double-claiming
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.
6535

6636
## Next Steps
6737

pages/restake/credits/precompile.mdx

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -110,108 +110,6 @@ contract CreditClaimer {
110110
}
111111
```
112112

113-
### Checking Available Credits
114-
115-
```solidity
116-
contract CreditChecker {
117-
Credits constant credits = Credits(0x0000000000000000000000000000000000000825);
118-
119-
function checkCredits(address user) external view returns (uint256) {
120-
// Calculate how many credits the user can claim
121-
return credits.calculateAccruedCredits(user);
122-
}
123-
124-
function checkEmissionRate(uint256 stakeAmount) external view returns (uint256) {
125-
// Get the emission rate for a given stake amount
126-
return credits.getCurrentRate(stakeAmount);
127-
}
128-
}
129-
```
130-
131-
### Integrating Credits in a Service
132-
133-
```solidity
134-
contract ServiceWithCredits {
135-
Credits constant credits = Credits(0x0000000000000000000000000000000000000825);
136-
137-
mapping(address => uint256) public userCredits;
138-
139-
function depositCredits(uint256 amount) external {
140-
// Check user has enough credits
141-
uint256 available = credits.calculateAccruedCredits(msg.sender);
142-
require(available >= amount, "Insufficient credits");
143-
144-
// Claim credits to this contract
145-
bytes memory contractId = abi.encodePacked(address(this));
146-
uint8 result = credits.claimCredits(amount, contractId);
147-
require(result == 0, "Credit claim failed");
148-
149-
// Track user's deposited credits
150-
userCredits[msg.sender] += amount;
151-
}
152-
153-
function useService(uint256 creditCost) external {
154-
require(userCredits[msg.sender] >= creditCost, "Insufficient deposited credits");
155-
userCredits[msg.sender] -= creditCost;
156-
157-
// Execute service logic here
158-
}
159-
}
160-
```
161-
162-
### Querying Stake Tiers
163-
164-
```solidity
165-
contract TierViewer {
166-
Credits constant credits = Credits(0x0000000000000000000000000000000000000825);
167-
168-
function getTierInfo() external view returns (
169-
uint256[] memory thresholds,
170-
uint256[] memory rates
171-
) {
172-
return credits.getStakeTiers();
173-
}
174-
175-
function findMyTier(uint256 myStake) external view returns (uint256 rate) {
176-
(uint256[] memory thresholds, uint256[] memory rates) = credits.getStakeTiers();
177-
178-
// Find the appropriate tier for the stake amount
179-
for (uint i = thresholds.length - 1; i >= 0; i--) {
180-
if (myStake >= thresholds[i]) {
181-
return rates[i];
182-
}
183-
}
184-
return 0; // Below minimum threshold
185-
}
186-
}
187-
```
188-
189-
## Events
190-
191-
### CreditsGrantedFromBurn
192-
193-
Emitted when TNT is burned for credits:
194-
195-
```solidity
196-
event CreditsGrantedFromBurn(
197-
address indexed account, // Account burning TNT
198-
uint256 burned, // Amount of TNT burned
199-
uint256 credits // Credits granted
200-
);
201-
```
202-
203-
### CreditsClaimed
204-
205-
Emitted when credits are claimed:
206-
207-
```solidity
208-
event CreditsClaimed(
209-
address indexed account, // Account claiming credits
210-
uint256 amount, // Amount of credits claimed
211-
bytes offchainAccountId // Off-chain account identifier
212-
);
213-
```
214-
215113
## Related Documentation
216114

217115
- [Credits Overview](/restake/credits/overview)

0 commit comments

Comments
 (0)