Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/EvmToSubstrateConverter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const AddressConverter = () => {
try {
const convertedAddress = evmToTangle(evmAddress);
setTangleAddress(convertedAddress);
} catch (error) {
} catch {
setTangleAddress("Invalid EVM address.");
}
};
Expand Down
2 changes: 1 addition & 1 deletion components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const Tabs: FC<{
const { data, mutate } = useSWR(storageKey, (key) => {
try {
return JSON.parse(localStorage.getItem(key) ?? "");
} catch (e) {
} catch {
return null;
}
});
Expand Down
31 changes: 24 additions & 7 deletions pages/developers/precompiles/features/multi-asset-delegation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ Below are example usages for some core methods on the multi-asset delegation int

1. Expand the `deposit(uint256 assetId, address tokenAddress, uint256 amount, uint8 lockMultiplier)` section.
2. Set `assetId` to `0` for ERC20 tokens, or provide another valid ID for other assets.
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.
3. Provide the ERC20 contract address in `tokenAddress` if `assetId` is `0`. For native assets, set this to the zero address.
4. Enter the `amount` you wish to deposit (in your asset's smallest unit, e.g., Wei for WETH).
5. Specify a `lockMultiplier` value if required by your delegation logic (`0` for no lock).
5. Specify a `lockMultiplier` value for lock duration rewards (`0` for no lock, higher values for increased rewards).
6. Click "transact" and confirm the MetaMask popup.

### 2. Schedule a Withdrawal

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

### 3. Execute a Scheduled Withdrawal

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

1. Expand `delegate(bytes32 operator, uint256 assetId, address tokenAddress, uint256 amount, uint64[] memory blueprintSelection)`.
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.
3. Click "transact" to nominate that account as your operator with a specified stake.
2. Enter the operator (as a bytes32 account ID), the asset ID, token address if assetId is `0` (ERC20), the amount to delegate.
3. Provide `blueprintSelection` as an array of blueprint IDs the operator should participate in.
4. Click "transact" to delegate your assets to the operator.

### 6. Schedule Unstake for Delegators

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

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

### 10. Check Delegated Balance

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

---

## Asset Types

- **Asset ID 0**: ERC20 tokens (requires token address)
- **Asset ID 1+**: Native or custom assets configured in the runtime

## Lock Multipliers

The `lockMultiplier` parameter in the deposit function allows users to lock their assets for longer periods in exchange for increased rewards:

- `0`: No lock (standard delegation)
- Higher values: Longer lock periods with proportionally higher reward multipliers

## Blueprint Selection

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.

## More Information

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.
7 changes: 4 additions & 3 deletions pages/developers/precompiles/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The precompiled contracts are categorized by address and based on the origin net
| Schnorr-Ristretto255 | Verifies Schnorr signatures using the Ristretto255 curve. | `0x000000000000000000000000000000000000081f` |
| Schnorr-Taproot | Verifies Schnorr signatures using the Taproot Scheme. | `0x0000000000000000000000000000000000000820` |
| Bls12-381 | Performs operations on the BLS12-381 curve. | `0x0000000000000000000000000000000000000821` |
| MultiAsset Delegation | Provides functions for managing multi-asset delegation pallet. | `0x0000000000000000000000000000000000000822` |
| Services Pallet | Provides functions for managing services pallet. | `0x0000000000000000000000000000000000000823` |
| Liqued Staking | Provides functions for managing liquid staking pallet. | `0x0000000000000000000000000000000000000824` |
| Tangle LST | Provides functions for managing liquid staking pools. | `0x0000000000000000000000000000000000000809` |
| MultiAsset Delegation | Provides functions for managing multi-asset delegation. | `0x0000000000000000000000000000000000000822` |
| Credits | Provides functions for managing cloud credits system. | `0x0000000000000000000000000000000000000825` |
| Services | Provides functions for managing service blueprints and instances. | `0x0000000000000000000000000000000000000900` |
1 change: 1 addition & 0 deletions pages/restake/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const meta: Meta = {
},
"restake-introduction": "Tangle Restaking",
incentives: "Incentives",
credits: "Tangle Credits",
how_to_restake: "How to Restake on Tangle",
restake_developers: "Developer Docs",
"-- liquid staking": {
Expand Down
9 changes: 9 additions & 0 deletions pages/restake/credits/_meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Meta } from "nextra";

const meta: Meta = {
index: "Overview",
claiming: "How to Claim Credits",
precompile: "Credits Precompile",
};

export default meta;
82 changes: 82 additions & 0 deletions pages/restake/credits/claiming.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: How to Claim Credits
description: Step-by-step guide to claiming your earned credits from the Cloud Credits pallet
---

# How to Claim Credits

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

## Prerequisites

- **Active TNT Stake**: You must have TNT staked through Tangle's multi-asset delegation system
- **Minimum Stake**: Your stake must meet the lowest tier threshold to earn credits
- **Off-chain Account**: An identifier linking your claim to off-chain credit management

## Claiming via Polkadot.js Apps

### Step 1: Connect to Tangle Network

1. Go to [Polkadot.js Apps](https://polkadot.js.org/apps)
2. Connect to the Tangle Network endpoint
3. Import or connect your account with TNT stake

### Step 2: Navigate to Extrinsics

1. Go to **Developer** → **Extrinsics**
2. Select your account from the dropdown
3. Choose `cloudCredits` from the pallet list
4. Select `claimCredits` from the call dropdown

### Step 3: Fill Parameters

**Amount to Claim (`amount_to_claim`):**

- Enter the number of credits you want to claim
- Must not exceed your accrued amount within the claim window
- Use the RPC query (see below) to check your maximum claimable amount

**Off-chain Account ID (`offchain_account_id`):**

- Your identifier for linking to off-chain credit systems
- Maximum length is configurable (check pallet constants)
- Keep this consistent across claims

![PolkadotJS Claim](/images/claim.png)

### Step 4: Submit Transaction

1. Click **Submit Transaction**
2. Enter your password if prompted
3. Confirm the transaction
4. Monitor the transaction status in the **Network** → **Explorer**

## Alternative: Asset-Specific Claims

For claiming credits from specific asset stakes:

1. Choose `claimCreditsWithAsset` instead of `claimCredits`
2. Add the **Asset ID** parameter for the specific asset
3. The same amount and off-chain account ID rules apply

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

## Events and Monitoring

### CreditsClaimed Event

When you successfully claim:

```
CreditsClaimed {
who: Your_Account_ID,
amount_claimed: Claimed_Amount,
offchain_account_id: Your_Offchain_ID
}
```

## Related Documentation

- [Credits Overview](/restake/credits) - Understanding the Cloud Credits pallet
- [Credits Precompile](/restake/credits/precompile) - Technical documentation for developers
- [How to Restake](/restake/how_to_restake) - Guide to staking TNT tokens
39 changes: 39 additions & 0 deletions pages/restake/credits/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: Credits
description: Earn free usage credits for AI tools by staking TNT tokens on Tangle.
---

# Credits

## What Are Credits?

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.

## How to Earn Credits

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.

## How to Use Your Credits

1. Stake TNT tokens on Tangle
2. Visit [ai.tangle.tools](https://ai.tangle.tools)
3. Claim your accumulated credits

### Earning Mechanism

Credits accumulate based on your staked TNT amount. Higher stake amounts earn credits at a higher rate.

### Credit Expiry

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.

This system encourages users to actively claim and use their credits rather than letting them pile up indefinitely.

### Claiming Process

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.

## Next Steps

- **[How to Claim Credits](/restake/credits/claiming)** - Learn how to claim your earned credits
- **[Credits Precompile](/restake/credits/precompile)** - Technical documentation for developers working with the credits system
99 changes: 99 additions & 0 deletions pages/restake/credits/precompile.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
title: Credits Precompile
description: Solidity interface for interacting with the Tangle Credits system
---

# Credits Precompile

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.

## Contract Address

- **Mainnet & Testnet**: `0x0000000000000000000000000000000000000825`

## Interface

```solidity
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.8.3;

/// @dev The Credits contract's address.
address constant CREDITS = 0x0000000000000000000000000000000000000825;

/// @dev The Credits contract's instance.
Credits constant CREDITS_CONTRACT = Credits(CREDITS);

/// @author The Tangle Team
/// @title Credits Pallet Interface
/// @notice Interface for interacting with the Tangle Credits system
/// @custom:address 0x0000000000000000000000000000000000000825
interface Credits {
/// @dev Burn TNT tokens to generate credits
/// @param amount The amount of TNT to burn
/// @return Success status (0 for success)
function burn(uint256 amount) external returns (uint8);

/// @dev Claim accumulated credits
/// @param amount The amount of credits to claim
/// @param offchainAccountId The off-chain account identifier
/// @return Success status (0 for success)
function claimCredits(
uint256 amount,
bytes calldata offchainAccountId
) external returns (uint8);

/// @dev Get the current credit emission rate for a staked amount
/// @param stakedAmount The amount of TNT staked
/// @return The credits earned per block
function getCurrentRate(uint256 stakedAmount) external view returns (uint256);

/// @dev Calculate accrued credits for an account
/// @param account The account to check
/// @return The amount of claimable credits
function calculateAccruedCredits(address account) external view returns (uint256);

/// @dev Get the current stake tier configuration
/// @return thresholds Array of stake thresholds
/// @return rates Array of emission rates per block
function getStakeTiers() external view returns (
uint256[] memory thresholds,
uint256[] memory rates
);

/// @dev Get stake tier for a specific asset
/// @param assetId The asset identifier
/// @return thresholds Array of stake thresholds
/// @return rates Array of emission rates per block
function getAssetStakeTiers(uint256 assetId) external view returns (
uint256[] memory thresholds,
uint256[] memory rates
);

/// @dev Events
event CreditsGrantedFromBurn(address indexed account, uint256 burned, uint256 credits);
event CreditsClaimed(address indexed account, uint256 amount, bytes offchainAccountId);
}
```

### Claiming Credits

```solidity
contract CreditClaimer {
Credits constant credits = Credits(0x0000000000000000000000000000000000000825);

function claimMyCredits(uint256 amount, string memory accountId) external {
// Convert string to bytes for off-chain account ID
bytes memory offchainId = bytes(accountId);

// Claim the credits
uint8 result = credits.claimCredits(amount, offchainId);
require(result == 0, "Claim failed");
}
}
```

## Related Documentation

- [Credits Overview](/restake/credits/overview)
- [Claiming Credits](/restake/credits/claiming)
- [Multi-Asset Delegation](/developers/precompiles/features/multi-asset-delegation)
2 changes: 2 additions & 0 deletions pages/restake/incentives/how_rewards_work.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Restaking rewards in the Tangle Network are designed to incentivize both operato
3. **Reward Vaults:** Asset Vaults to which restaked tokens are assigned for reward distribution.
4. **Delegators:** Users who delegate their tokens to operators, sharing in the rewards generated by the operators' activities.
5. **Operators:** Validators who restake their tokens and provide services, earning rewards through their participation in the restaking protocol.
6. **Lock Duration Multipliers:** Enhanced rewards for longer lock periods (1.1x to 1.6x multipliers).
7. **Service-Specific Rewards:** Rewards tied to specific service blueprints and instances.

## Whitelisting Blueprints for Rewards

Expand Down
Loading