Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hack.chat Solana Smart Contract

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.

Network Architecture & Vanity Addresses

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.

Architecture & State

The smart contract manages two primary Program Derived Addresses (PDAs):

  1. ChannelState PDA:
    • 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.
  2. DonationState PDA:
    • Seeds: [b"donation", user_wallet_pubkey]
    • Purpose: A 2-byte ledger that records a user's global chat effect ID.

Instruction Set

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.

Chat Effects Demo

The visual name effects unlocked via the RecordDonation instruction can be previewed interactively. View the Live Effects Demo Here


Building & Testing

Prerequisites

Build the Program

To compile the smart contract into a deployable .so SBF (Solana Bytecode Format) binary:

cargo build-sbf

Run Tests

The test suite utilizes standard cargo test configurations:

cargo test

About

solana smart contract for the hack.chat ecosystem

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages