This repository contains the native Rust Solana smart contract (program) for the hack.chat ecosystem. It governs decentralized channel ownership, on-chain moderator delegation, and a server donation system that unlocks global chat effects.
Built without heavy frameworks (like Anchor), this program uses raw Native Rust architecture to minimize compute budget and reduce user rent costs.
This program utilizes three distinct addresses to separate logic, treasury funds, and asset verification:
- Smart Contract (Program ID):
AutHysEUfKrWDETzrDA7S7MwL1eSSc2BjySR2W8EuSEr- The executable logic handling all PDA state changes, user authentication, and authorization.
- Project Treasury:
HaCKy1tUTBDkfUkcYcUFkhC887ucAs3tEjcmqRa5cHat- The public vault that receives all protocol fees and direct SOL donations.
- Master NFT Collection:
HaCkAvuxxfnfNLfnENxQ1V3aHCjgDS1rMNYcm4qWsYNC- The root Metaplex Collection Mint used to cryptographically sync and verify channel-ownership NFTs.
The smart contract manages two primary Program Derived Addresses (PDAs):
ChannelStatePDA:- Seeds:
[b"channel", channel_name_bytes] - Purpose: Stores the channel name, the owner's wallet address, the required NFT Address, and an array of up to 20 authorized moderator tripcodes.
- Seeds:
DonationStatePDA:- Seeds:
[b"donation", user_wallet_pubkey] - Purpose: A 2-byte ledger that records a user's global chat effect ID.
- Seeds:
| Instruction | Description |
|---|---|
ClaimChannel |
Initializes a ChannelState PDA. Requires the signer to hold the channel's NFT. |
ReclaimChannel |
Allows an NFT holder to overwrite the owner_wallet of an existing channel and wipe the moderator list. |
AssignModerator |
Allows the channel owner to add a 6-character tripcode to the on-chain moderator array. |
RemoveModerator |
Allows the channel owner to revoke a tripcode's moderation privileges. |
CloseChannel |
Closes the channel PDA, wipes the data, and refunds the storage rent back to the owner. |
RecordDonation |
Performs a CPI transfer of SOL to the HaCKy...5cHat treasury wallet and updates the user's DonationState PDA with a chat effect ID. |
The visual name effects unlocked via the RecordDonation instruction can be previewed interactively.
View the Live Effects Demo Here
- Rust
- Solana CLI (
v1.16or higher)
To compile the smart contract into a deployable .so SBF (Solana Bytecode Format) binary:
cargo build-sbfThe test suite utilizes standard cargo test configurations:
cargo test