You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand c-token-program overview with compressible extension details
- Add comprehensive compressible extension documentation with rent mechanics
- Add BaseMint struct code example in new tab alongside comparison table
- Add ATA derivation code example showing seed construction
- Reorder compressed token use cases: storage first, then distribution
- Simplify cmint.mdx: remove duplicate core concepts, link to main overview
- Update ctoken.mdx: remove redundant sections covered in main overview
- Add placeholder note for token type graphic
- Fix source code link to ctoken_struct.rs
@@ -43,14 +43,17 @@ The [Compressed Token Program](https://github.com/Lightprotocol/light-protocol/t
43
43
<ul>
44
44
<li>**Compressed account** with `TokenData` field</li>
45
45
<li>**Rent-free** and SPL-compatible</li>
46
-
<li>Use for **token distribution**(airdrops, payments, etc.) and **storage of inactive tokens**</li>
46
+
<li>Use for **storage of inactive tokens**or **token distribution**</li>
47
47
<li>cToken accounts with the **[compressible extension](#compressible) are automatically compressed/decompressed** when active/inactive.</li>
48
48
</ul>
49
49
</td>
50
50
</tr>
51
51
</tbody>
52
52
</table>
53
53
54
+
_add graphic of all tokens here_
55
+
56
+
54
57
<Tip>
55
58
**SPL mints and tokens** owned by the [Token Program](https://github.com/solana-program/token) or [Token-2022](https://github.com/solana-program/token-2022)**require rent** by default.<br />
56
59
You can **migrate SPL token accounts to cTokens** with compressible extension for **sponsored rent-exemption** while keeping the **same interoparability**.
@@ -63,9 +66,10 @@ You can **migrate SPL token accounts to cTokens** with compressible extension fo
63
66
* SPL mints can not be compressed to cMints.
64
67
</Note>
65
68
66
-
cMints **uniquely represent a token on Solana and store its global metadata**, similar to SPL mint accounts with two core differences:
69
+
cMints **uniquely represent a token on Solana and store its global metadata**, similar to SPL mint accounts with few core differences:
67
70
1. cMint accounts are **rent-free**.
68
71
2. Tokens created from cMints are **cTokens** (fully compatible with SPL tokens).
72
+
3. Token metadata (name, symbol, URI) is stored as an extension within the compressed mint account.
69
73
70
74
<Tabs>
71
75
<Tabtitle="Diagram">
@@ -99,52 +103,76 @@ The `metadata` field is used by the Compressed Token Program to store the intern
99
103
The `BaseMint` field replicates the field layout and serialization format of [SPL Mint accounts](https://solana.com/docs/tokens#mint-account). The struct is serialized with Borsh to match the on-chain format of SPL tokens and mints.
/// Optional authority used to mint new tokens. The mint authority may only
160
+
/// be provided during mint creation. If no mint authority is present
161
+
/// then the mint has a fixed supply and no further tokens may be
162
+
/// minted.
163
+
pubmint_authority:Option<Pubkey>,
164
+
/// Total supply of tokens.
165
+
pubsupply:u64,
166
+
/// Number of base 10 digits to the right of the decimal place.
167
+
pubdecimals:u8,
168
+
/// Is initialized - for SPL compatibility
169
+
pubis_initialized:bool,
170
+
/// Optional authority to freeze token accounts.
171
+
pubfreeze_authority:Option<Pubkey>,
172
+
}
173
+
```
174
+
</Tab>
175
+
</Tabs>
148
176
149
177
# cToken Account
150
178
@@ -157,11 +185,6 @@ A cToken account holds token balances like SPL Token accounts:
157
185
* Each wallet can own multiple cToken accounts for the same cMint.
158
186
* A cToken account can only have one owner and hold units of one cMint.
159
187
160
-
<Tip>
161
-
* Use the **[compressible extension](/compressible/compressible) for sponsored rent exemption**.
162
-
* cToken accounts with this extension are **automatically compressed** with no writes in 6300 slots (1.75 hours), **and decompressed** with new writes.
163
-
</Tip>
164
-
165
188
<Tabs>
166
189
<Tabtitle="Diagram">
167
190
<Frame>
@@ -190,7 +213,7 @@ A cToken account holds token balances like SPL Token accounts:
190
213
</Tabs>
191
214
192
215
<Info>
193
-
Find the [source code of cToken here](https://github.com/Lightprotocol/light-protocol/blob/main/program-libs/ctoken-types/src/state/ctoken/ctoken.rs).
216
+
Find the [source code of cToken here](https://github.com/Lightprotocol/light-protocol/blob/main/program-libs/ctoken-types/src/state/ctoken/ctoken_struct.rs).
194
217
</Info>
195
218
196
219
cToken accounts replicate the field layout and serialization format of [SPL Token accounts](https://solana.com/docs/tokens#token-account). The struct is serialized with Borsh to match the on-chain format of SPL tokens.
@@ -253,38 +276,188 @@ Here is how cTokens and SPL tokens compare:
253
276
</tbody>
254
277
</table>
255
278
256
-
#Associated cToken Account
279
+
### Compressible Extension
257
280
258
-
**Associated cToken** accounts follow the same pattern as [associated token accounts](https://docs.solana.com/developing/programming-model/associated-token-account) (ATA):
259
-
* Each wallet needs its own cToken account to hold tokens from the same cMint.
260
-
* It's derived from the owner's address and the cMint account's address.
261
-
* The only **difference** in ATA derivation is the **program ID parameter**.
281
+
Compressible accounts maintain the **functionality of Solana accounts** but with **rent-exemption sponsorship**:
282
+
283
+
1. The protocol funds the account's rent exemption (rent sponsor) at creation.
284
+
2. The account creator top-ups the lamport balance with rent for at least two epochs (12,600 slots / 84 min)
285
+
3. The transaction payer top-ups the lamports balance when the account's lamports balance is below 2 epochs.
286
+
4. The account will be compressed when inactive for a period of 12,600 slots (84 min).
287
+
5. When the account is written to, it's automatically decompressed.
288
+
<Tip>
289
+
We recommend to create cToken accounts always with the [compressible extension](/compressible/compressible) for sponsored rent exemption.
290
+
</Tip>
291
+
This extension makes cToken accounts 200x cheaper than SPL token accounts
292
+
293
+
|| cToken | SPL |
294
+
|-----------|--------|-----|
295
+
| allocate | 0.000011 | 0.002 |
296
+
| rent for 24h | 0.000005 | - |
297
+
298
+
<Accordiontitle="Compressible vs Solana Rent">
299
+
300
+
### Initial Rent Top-Up
301
+
The **creator of compressible accounts** tops-up the account with **rent for at least two epochs**.
302
+
Two epochs for compressible accounts have a length of **12,600 slots**.
* Most Solana accounts are rarely accessed after creation, but continue to lock up SOL for the account's lifetime.
356
+
* The creator of Solana accounts still must pay the rent-exemption balance.
357
+
* The creator of compressible accounts only needs to pay the rent for the first two epochs.
358
+
</Note>
359
+
360
+
361
+
### Top-ups per Transaction
362
+
363
+
The **transaction payer tops-up** the account with rent **when the account's lamports balance is below 2 epochs**. This keeps accounts decompressed while active.
**Associated cToken** accounts follow the same pattern as [associated token accounts](https://docs.solana.com/developing/programming-model/associated-token-account) (ATA):
447
+
* Each wallet needs its own cToken account to hold tokens from the same cMint.
448
+
* It's derived with the owner's address, program ID, and mint address.
449
+
* The only **difference** in ATA derivation is the **program ID parameter** used in the seeds.
450
+
451
+
452
+
```rust
453
+
letseeds= [
454
+
owner.as_ref(), // Wallet address (32 bytes)
455
+
program_id.as_ref(), // Compressed Token Program ID (32 bytes)
456
+
mint.as_ref(), // cMint address (32 bytes)
457
+
bump.as_ref(), // Bump seed (1 byte)
458
+
];
459
+
```
460
+
288
461
<Info>
289
462
Find the [source code to associated cToken accounts here](https://github.com/Lightprotocol/light-protocol/blob/main/programs/compressed-token/program/src/create_associated_token_account.rs).
290
463
</Info>
@@ -297,7 +470,7 @@ cToken ATAs can implement the **[compressible extension](/compressible/compressi
297
470
298
471
Compressed token accounts store token balance, owner, and other information like SPL and cTokens. Any cToken or SPL token can be compressed/decompressed at will.
299
472
300
-
We recommend to use compressed tokens for token distribution or storage of inactive tokens.
473
+
We recommend to use compressed tokens for **token distribution** or **storage of inactive tokens**.
301
474
<Tip>
302
475
**cToken accounts** with the **[compressible extension](/compressible/compressible) are automatically compressed** with no writes in 6300 slots (1.75 hours), and decompressed with new writes.
0 commit comments