Hidden is on X. Follow @gohiddenfun
Docs · The lock

Read the program that locks every coin.

A coin launched on Hidden trades here and nowhere else. That is not a promise from this site. It is one small program on Solana, and this is all of it: 228 lines, no keys, nothing left out.

On Solana right now

The first hash is taken from the program's account on Solana when you open this page. The second is what the source below compiles to. The same hash means the same program, down to the last byte.

Reading the program from Solana…
Program
8gvZEFLFrZUrotj75dDBjdK9uBCiqwqmWRXFWe1NqhoT
Code on SolanaSHA-256 of what is deployed
This page's sourceSHA-256 of what it builds to
342a785b4d94ca03f355c98cf5ca111a6c4448cae9445840512754499a61a102
Signature it asks forA public key. The secret half stays on the launchpad's server.
Can name another signer
Can replace the code
Last deployed

How it works

Four facts, and the function that carries the whole rule.

  1. 01

    The coin points at the program

    Every coin launched here is a Token-2022 token with a transfer hook, and the hook is this program. Token-2022 calls it on every transfer of the coin: a buy, a sell, a send. The call cannot be skipped, because it is Token-2022 that makes it.

  2. 02

    The program looks for one signature

    execute reads which key it trusts from its own account (line 76), then goes through every instruction of the transaction, as Solana itself lists them, looking for that key among the signers (line 80).

  3. 03

    No signature, no transfer

    If the key signed, the transfer goes through (line 84). If it did not, the program answers with error 0x1001 (line 89) and the whole transaction fails. A terminal can show the coin and its chart, but it cannot make that signature.

  4. 04

    Only the launchpad can give it

    The secret half of the key is on the launchpad's server, which signs a transaction only when all it does is buy, sell or launch on the launchpad's own curve. The program never holds a secret: every key in its source and in its accounts is a public one.

src/lib.rs
68/// Called by Token-2022 on every transfer of a gated coin.69///70/// Accounts: source, mint, destination, authority, extra-account-metas, config, instructions sysvar.71#[inline(never)]72fn execute(program_id: &Address, accounts: &[AccountView]) -> ProgramResult {73    let [_source, _mint, _destination, _authority, _metas, config, instructions, ..] = accounts else {74        return Err(ProgramError::NotEnoughAccountKeys);75    };76    let gate_signer = read_config(program_id, config)?.1;77
78    // `try_from` refuses any account but the real sysvar, so the list below is the transaction's own.79    let instructions = Instructions::try_from(instructions)?;80    for index in 0..instructions.num_instructions() {81        let instruction = instructions.load_instruction_at(index)?;82        for position in 0..instruction.num_account_metas() {83            let account = instruction.get_instruction_account_at(position)?;84            if account.is_signer() && account.key == gate_signer {85                return Ok(());86            }87        }88    }89    Err(ProgramError::Custom(NOT_PERMITTED))90}

The source

One file. Click a line number to link to that line. Nothing here is a secret: the program is public on Solana either way, and it only ever handles public keys.

src/lib.rsRaw
1//! The gate: a Token-2022 transfer hook that makes a coin tradable only with2//! the launchpad's signature.3//!4//! Every coin launched on Hidden names this program as its transfer hook, so5//! Token-2022 calls it on every transfer of the coin. The transfer goes6//! through only when the transaction carries a signature from the gate signer,7//! a key the launchpad's server holds. A trade built anywhere else has no such8//! signature and fails.9//!10//! What this does not do: it does not hide token accounts. Who holds how much11//! is still public; the gate only decides which transactions may move a coin.12#![no_std]13
14use pinocchio::{15    cpi::{Seed, Signer},16    error::ProgramError,17    no_allocator, nostd_panic_handler, program_entrypoint,18    sysvars::{instructions::Instructions, rent::Rent, Sysvar},19    AccountView, Address, ProgramResult,20};21use pinocchio_system::instructions::{Allocate, Assign, CreateAccount, Transfer};22
23program_entrypoint!(process_instruction, 16);24no_allocator!();25nostd_panic_handler!();26
27/// `sha256("spl-transfer-hook-interface:execute")[..8]`: how Token-2022 addresses the hook.28const EXECUTE: [u8; 8] = [105, 37, 101, 197, 75, 251, 102, 26];29
30const CONFIGURE: u8 = 0;31const INIT_MINT: u8 = 1;32const PERMIT: u8 = 2;33
34const CONFIG_SEED: &[u8] = b"gate";35/// Fixed by the transfer hook interface: Token-2022 looks the account up under this seed and the mint.36const METAS_SEED: &[u8] = b"extra-account-metas";37
38const CONFIG_VERSION: u8 = 1;39/// version (1) + admin (32) + gate signer (32)40const CONFIG_LEN: usize = 65;41/// The accounts Token-2022 must hand the hook on top of the transfer's own: the config and the instructions sysvar.42const EXTRA_ACCOUNTS: usize = 2;43/// One entry: kind (1) + address (32) + is signer (1) + is writable (1)44const META_LEN: usize = 35;45/// discriminator (8) + length (4) + count (4) + entries46const METAS_LEN: usize = 16 + EXTRA_ACCOUNTS * META_LEN;47
48const UPGRADEABLE_LOADER: Address = Address::from_str_const("BPFLoaderUpgradeab1e11111111111111111111111");49const INSTRUCTIONS_SYSVAR: Address = Address::from_str_const("Sysvar1nstructions1111111111111111111111111");50
51/// The transaction does not carry the gate signer's signature.52const NOT_PERMITTED: u32 = 0x1001;53/// Only the admin (at first: the program's upgrade authority) may configure the gate.54const NOT_ADMIN: u32 = 0x1002;55
56pub fn process_instruction(program_id: &Address, accounts: &mut [AccountView], data: &[u8]) -> ProgramResult {57    if data.len() >= 8 && data[..8] == EXECUTE {58        return execute(program_id, accounts);59    }60    match data.split_first() {61        Some((&CONFIGURE, rest)) => configure(program_id, accounts, rest),62        Some((&INIT_MINT, _)) => init_mint(program_id, accounts),63        Some((&PERMIT, _)) => permit(accounts),64        _ => Err(ProgramError::InvalidInstructionData),65    }66}67
68/// Called by Token-2022 on every transfer of a gated coin.69///70/// Accounts: source, mint, destination, authority, extra-account-metas, config, instructions sysvar.71#[inline(never)]72fn execute(program_id: &Address, accounts: &[AccountView]) -> ProgramResult {73    let [_source, _mint, _destination, _authority, _metas, config, instructions, ..] = accounts else {74        return Err(ProgramError::NotEnoughAccountKeys);75    };76    let gate_signer = read_config(program_id, config)?.1;77
78    // `try_from` refuses any account but the real sysvar, so the list below is the transaction's own.79    let instructions = Instructions::try_from(instructions)?;80    for index in 0..instructions.num_instructions() {81        let instruction = instructions.load_instruction_at(index)?;82        for position in 0..instruction.num_account_metas() {83            let account = instruction.get_instruction_account_at(position)?;84            if account.is_signer() && account.key == gate_signer {85                return Ok(());86            }87        }88    }89    Err(ProgramError::Custom(NOT_PERMITTED))90}91
92/// Gives the gate signer a place in a transaction. It has to sign for the instruction to be accepted at all.93///94/// Accounts: gate signer (signer).95fn permit(accounts: &[AccountView]) -> ProgramResult {96    match accounts.first() {97        Some(signer) if signer.is_signer() => Ok(()),98        _ => Err(ProgramError::MissingRequiredSignature),99    }100}101
102/// Sets the admin and the gate signer. The first call must be signed by the103/// program's upgrade authority; later ones by the admin it named.104///105/// Accounts: authority (signer, writable), config (writable), system program, program data (first call only).106/// Data: admin (32) + gate signer (32).107#[inline(never)]108fn configure(program_id: &Address, accounts: &mut [AccountView], data: &[u8]) -> ProgramResult {109    if data.len() != 64 {110        return Err(ProgramError::InvalidInstructionData);111    }112    let [authority, config, _system_program, rest @ ..] = accounts else {113        return Err(ProgramError::NotEnoughAccountKeys);114    };115    if !authority.is_signer() {116        return Err(ProgramError::MissingRequiredSignature);117    }118    let (address, bump) = Address::find_program_address(&[CONFIG_SEED], program_id);119    if config.address() != &address {120        return Err(ProgramError::InvalidSeeds);121    }122
123    if config.owned_by(program_id) {124        let admin = read_config(program_id, config)?.0;125        if authority.address() != &admin {126            return Err(ProgramError::Custom(NOT_ADMIN));127        }128    } else {129        let Some(program_data) = rest.first() else {130            return Err(ProgramError::NotEnoughAccountKeys);131        };132        if authority.address() != &upgrade_authority(program_id, program_data)? {133            return Err(ProgramError::Custom(NOT_ADMIN));134        }135        let bump = [bump];136        create(authority, config, CONFIG_LEN, program_id, &[Seed::from(CONFIG_SEED), Seed::from(&bump)])?;137    }138
139    let mut stored = config.try_borrow_mut()?;140    stored[0] = CONFIG_VERSION;141    stored[1..CONFIG_LEN].copy_from_slice(data);142    Ok(())143}144
145/// Creates the account that tells Token-2022 which extra accounts the hook146/// needs for one mint. Anyone may do this for any mint: the content is fixed.147///148/// Accounts: payer (signer, writable), mint, extra-account-metas (writable), system program.149#[inline(never)]150fn init_mint(program_id: &Address, accounts: &mut [AccountView]) -> ProgramResult {151    let [payer, mint, metas, _system_program, ..] = accounts else {152        return Err(ProgramError::NotEnoughAccountKeys);153    };154    let (address, bump) = Address::find_program_address(&[METAS_SEED, mint.address().as_array()], program_id);155    if metas.address() != &address {156        return Err(ProgramError::InvalidSeeds);157    }158    if metas.owned_by(program_id) {159        return Ok(());160    }161    let bump = [bump];162    let seeds = [Seed::from(METAS_SEED), Seed::from(mint.address().as_array()), Seed::from(&bump)];163    create(payer, metas, METAS_LEN, program_id, &seeds)?;164
165    let config = Address::find_program_address(&[CONFIG_SEED], program_id).0;166    let mut stored = metas.try_borrow_mut()?;167    stored[..8].copy_from_slice(&EXECUTE);168    stored[8..12].copy_from_slice(&((4 + EXTRA_ACCOUNTS * META_LEN) as u32).to_le_bytes());169    stored[12..16].copy_from_slice(&(EXTRA_ACCOUNTS as u32).to_le_bytes());170    // Kind 0 is a fixed address; neither account signs or is written to.171    for (index, extra) in [config, INSTRUCTIONS_SYSVAR].iter().enumerate() {172        let start = 16 + index * META_LEN;173        stored[start] = 0;174        stored[start + 1..start + 33].copy_from_slice(extra.as_array());175        stored[start + 33] = 0;176        stored[start + 34] = 0;177    }178    Ok(())179}180
181/// (admin, gate signer). Only this program can own an account, and the config is the only one it makes this size.182fn read_config(program_id: &Address, config: &AccountView) -> Result<(Address, Address), ProgramError> {183    if !config.owned_by(program_id) {184        return Err(ProgramError::InvalidAccountOwner);185    }186    let stored = config.try_borrow()?;187    if stored.len() != CONFIG_LEN || stored[0] != CONFIG_VERSION {188        return Err(ProgramError::InvalidAccountData);189    }190    let mut admin = [0u8; 32];191    let mut gate_signer = [0u8; 32];192    admin.copy_from_slice(&stored[1..33]);193    gate_signer.copy_from_slice(&stored[33..65]);194    Ok((Address::new_from_array(admin), Address::new_from_array(gate_signer)))195}196
197/// Who may upgrade this program, read from the loader's own record of it.198fn upgrade_authority(program_id: &Address, program_data: &AccountView) -> Result<Address, ProgramError> {199    let expected = Address::find_program_address(&[program_id.as_array()], &UPGRADEABLE_LOADER).0;200    if program_data.address() != &expected || !program_data.owned_by(&UPGRADEABLE_LOADER) {201        return Err(ProgramError::InvalidAccountOwner);202    }203    let stored = program_data.try_borrow()?;204    // Layout: account kind (u32, 3 = program data), deploy slot (u64), has authority (u8), authority (32).205    if stored.len() < 45 || stored[..4] != [3, 0, 0, 0] || stored[12] != 1 {206        return Err(ProgramError::Custom(NOT_ADMIN));207    }208    let mut authority = [0u8; 32];209    authority.copy_from_slice(&stored[13..45]);210    Ok(Address::new_from_array(authority))211}212
213/// Creates a program-owned account at a derived address. If someone sent214/// lamports there first, a plain create would fail, so it is topped up,215/// sized and assigned instead.216fn create(payer: &AccountView, account: &AccountView, space: usize, owner: &Address, seeds: &[Seed]) -> ProgramResult {217    let signer = [Signer::from(seeds)];218    let rent = Rent::get()?.try_minimum_balance(space)?;219    if account.lamports() == 0 {220        return CreateAccount { from: payer, to: account, lamports: rent, space: space as u64, owner }.invoke_signed(&signer);221    }222    let missing = rent.saturating_sub(account.lamports());223    if missing > 0 {224        Transfer { from: payer, to: account, lamports: missing }.invoke()?;225    }226    Allocate { account, space: space as u64 }.invoke_signed(&signer)?;227    Assign { account, owner }.invoke_signed(&signer)228}

It is built on two small libraries, which give it Solana's basic types and the system program's instructions. Their exact versions are pinned in Cargo.lock.

Cargo.tomlRaw
[package]name = "hidden-gate"version = "0.1.0"edition = "2021"publish = false
[lib]crate-type = ["cdylib"]
[dependencies]pinocchio = { version = "0.12", features = ["cpi"] }pinocchio-system = "0.7"
[profile.release]opt-level = "z"lto = "fat"codegen-units = 1overflow-checks = truepanic = "abort"

Check it yourself

A page can say anything. These checks ask Solana instead, from your own machine, with the standard Solana tools.

  1. Check 1

    Hash the program Solana runs

    Download the deployed program straight from the chain and hash it.

    Terminal
    solana program dump -u mainnet-beta 8gvZEFLFrZUrotj75dDBjdK9uBCiqwqmWRXFWe1NqhoT gate.sosha256sum gate.so# 342a785b4d94ca03f355c98cf5ca111a6c4448cae9445840512754499a61a102  gate.so
  2. Check 2

    Build the source and hash that

    Compile the three files from this page. The hash is the same as in check 1, which means the program on Solana contains this source and nothing else.

    Terminal
    mkdir -p gate/src && cd gatecurl -sO https://gohidden.fun/docs/source/Cargo.tomlcurl -sO https://gohidden.fun/docs/source/Cargo.lockcurl -s https://gohidden.fun/docs/source/lib.rs -o src/lib.rscargo-build-sbfsha256sum target/deploy/hidden_gate.so# 342a785b4d94ca03f355c98cf5ca111a6c4448cae9445840512754499a61a102  target/deploy/hidden_gate.so

    Built with cargo-build-sbf 4.5.0, platform-tools v1.57. Another version of the tools can turn the same source into different bytes.

  3. Check 3

    See that a coin points at it

    Take any coin's address from its page here. This one is PROOF. Under “Transfer Hook” the program is 8gvZ…qhoT, the one on this page.

    Terminal
    spl-token display -u mainnet-beta 9mbjbEha5Gu3mkb8m8YmnFE7kKCCeY5V2X928FA3caDw
  4. Check 4

    Try to buy one somewhere else

    Paste a coin's address into any trading terminal or aggregator and try to buy it. The chart loads. The trade fails with custom program error: 0x1001, or the terminal says the coin cannot be traded.

    The one exception is Hidden's own coin, marked Official on the coin list. It is an ordinary token without the hook, and it trades anywhere.

Seen on mainnet

One coin, PROOF, and one wallet, within two minutes. Three transactions went through the site. The fourth was the same buy sent straight to the chain.

Open the failed one and read its log. The program that refused it is 8gvZ…qhoT, and the three that went through each carry the launchpad's signature, from the key listed at the top of this page.

What it does not do

The source shows what the lock is. It also shows where it stops.

  • It moves nothing. The check reads two accounts and answers yes or no. It cannot take a coin or SOL from anyone.
  • It can be replaced. The address under “Can replace the code” can deploy another version. If that happens, the hash at the top of this page stops matching and the page says so.
  • The signer can be changed. The admin can name another key (configure). That is how a leaked key would be shut out.
  • It checks who signed, not why. Which transactions the launchpad signs is decided on its server, and while that server is offline nothing trades. Who you rely on.
  • It does not hide addresses. Who holds how much of a coin is public on Solana. What keeps a holder private is a fresh wallet paid out of the pool.
  • It holds no key. The source has public keys in it and nothing else. The one secret, the signer's, never leaves the launchpad's server.