KOR is coming soon!

NEW
BASICS
Building on Kontor means tapping into a platform that combines security, scalability, and seamless integration, all tailored for seamless Bitcoin-based development.

Key Reasons to Choose Kontor

use anchor_lang::prelude::*;

declare_id!("SocksSale111111111111111111111111111111111111");

#[program]
pub mod unisocks_sale {
    use super::*;

    pub fn initialize(ctx: Context<Initialize>, m: u64) -> Result<()> {
        let state = &mut ctx.accounts.state;
        state.sold = 0;
        state.m = m;
        Ok(())
    }

    pub fn buy_sock(ctx: Context<BuySock>) -> Result<()> {
        let state = &mut ctx.accounts.state;
        require!(state.sold < 500, SocksError::SoldOut);

        let n = state.sold;
        let m = state.m;

        let price = calculate_price(m, n)?;
        let payer = &mut ctx.accounts.buyer;
        let treasury = &mut ctx.accounts.treasury;

        // Ensure payment is correct
        require!(payer.lamports() >= price, SocksError::InsufficientPayment);

        // Transfer lamports to treasury
        **payer.try_borrow_mut_lamports()? -= price;
        **treasury.try_borrow_mut_lamports()? += price;

        // Increment sold count
        state.sold += 1;

        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(init, payer = payer, space = 8 + 8 + 8)]
    pub state: Account<'info, SaleState>,
    #[account(mut)]
    pub payer: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[derive(Accounts)]
pub struct BuySock<'info> {
    #[account(mut)]
    pub state: Account<'info, SaleState>,
    #[account(mut)]
    pub buyer: Signer<'info>,
    /// CHECK: safe because this is a system account for treasury
    #[account(mut)]
    pub treasury: AccountInfo<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
pub struct SaleState {
    pub sold: u64,  // number of socks sold (n)
    pub m: u64,     // bonding curve parameter M
}

#[error_code]
pub enum SocksError {
    #[msg("All 500 socks have been sold.")]
    SoldOut,
    #[msg("Not enough payment for the current sock price.")]
    InsufficientPayment,
}

fn calculate_price(m: u64, n: u64) -> Result<u64> {
    require!(n < 500, SocksError::SoldOut);

    let a = m.checked_div(500 - n).ok_or(SocksError::SoldOut)?;
    let b = m.checked_div(501 - n).ok_or(SocksError::SoldOut)?;
    let price = a.checked_sub(b).ok_or(SocksError::SoldOut)?;
    Ok(price)
}

Security First
Kontor harnesses offline Bitcoin storage and cutting-edge cryptographic techniques to deliver the same trustless security that makes Bitcoin legendary.

Scalable Infrastructure
Built with modular architecture, Kontor enables apps and infrastructure to scale effortlessly, reducing friction for developers.

Developer-Centric Tools
With SDKs, clear documentation, and sample code, building on Kontor is a matter of hours—not days.

Built for Bitcoin
Leverages Bitcoin as the underlying trust anchor, inheriting its decentralization, immutability, and widespread user confidence.

High Liquidity Potential
Access to a vibrant, capital-rich ecosystem via Bitcoin-centric DeFi protocols and integrations.

“Building on Kontor felt like a natural extension of Bitcoin secure, intuitive, and ready for real-world use.”

— Jane Doe, Lead Developer at Acme Protocol

Discover Horizon

How Kontor Stands Out

Developers and users retain control—no intermediaries, no key custody risk.

Get Started Bulding

  1. Explore the docs – Dive into our Developer Guide to learn setup and workflows.
  2. Try your sample app – Scaffold a new project using the CLI in under 2 minutes.
  3. Join the community – Chat on Discord, browse GitHub issues, or follow along with live Q&A sessions.
  4. Launch – Deploy with confidence, backed by Bitcoin, Kontor tools, and ongoing support.

Wrap-Up Thoughts

Whether you’re launching the next Bitcoin-powered DeFi app, a secure wallet, or a cross-chain protocol, Kontor offers you the foundational trust and tools to build smarter and faster. With Bitcoin at its core, rich tooling, and a developer-first design—Kontor is where innovation meets legacy-grade blockchain security.

Whether you’re launching the next Bitcoin-powered DeFi app, a secure wallet, or a cross-chain protocol, Kontor offers you the foundational trust and tools to build smarter and faster. With Bitcoin at its core, rich tooling, and a developer-first design—Kontor is where innovation meets legacy-grade blockchain security.

Additional Resources

Continue Reading
NEW
BASICS

Architecture + Consensus