Technical Specifications

Market.fun is built upon the robust and high-performance Solana blockchain. Solana's innovative architecture enables high throughput and low transaction fees, providing a seamless and efficient user experience for creating, trading, and managing AI agents. The platform leverages Solana's smart contract capabilities to ensure transparency and security in all transactions, guaranteeing the integrity of the ecosystem and user interactions.

  • Blockchain: Solana

  • Token Standard: SPL

  • Programming Language: Rust

  • Consensus Mechanism: Proof of Stake

  • AI Framework: Gemini AI

  • IPFS

Smart Contract Implementation

The core functionality of Market.fun is implemented through a set of smart contracts written in Rust using the Anchor framework. These smart contracts govern the creation, management, and trading of AI agents and their associated tokens, ensuring a secure and transparent environment for all platform operations.

Launch Instruction

The Launch instruction within the smart contract handles the creation and configuration of new AI agents and their tokens. It defines the necessary accounts and programs involved in the process, including the global configuration, creator's account, token mint account, bonding curve account, and metadata account. The instruction also includes validation checks to ensure the integrity of the input parameters and the proper authorization of the involved accounts.

Code Snippet

use std::ops::{Div, Mul};


use crate::{
constants::{BONDING_CURVE, CONFIG, GLOBAL, METADATA},
errors::*,
events::LaunchEvent,
state::{BondingCurve, Config},
};
use anchor_lang::{prelude::*, solana_program::sysvar::SysvarId, system_program};
use anchor_spl::{
associated_token::{self, AssociatedToken},
metadata::{self, mpl_token_metadata::types::DataV2, Metadata},
token::{self, spl_token::instruction::AuthorityType, Mint, Token},
};


#[derive(Accounts)]
#[instruction(decimals: u8)]
pub struct Launch<'info> {
 #[account(
mut,
 seeds = [CONFIG.as_bytes()],
bump,
 )]
global_config: Box<Account<'info, Config>>,


/// CHECK: global vault pda which stores SOL
 #[account(
mut,
 seeds = [GLOBAL.as_bytes()],
bump,
 )]
pub global_vault: AccountInfo<'info>,


 #[account(mut)]
creator: Signer<'info>,


 #[account(
 init,
 payer = creator,
 mint::decimals = decimals,
 mint::authority = global_vault.key(),
 )]
token: Box<Account<'info, Mint>>,


 #[account(
 init,
 payer = creator,
 space = 8 + std::mem::size_of::<BondingCurve>(),
 seeds = [BONDING_CURVE.as_bytes(), &token.key().to_bytes()],
bump
 )]
bonding_curve: Box<Account<'info, BondingCurve>>,


/// CHECK: passed to token metadata program
 #[account(
mut,
 seeds = [
METADATA.as_bytes(),
 metadata::ID.as_ref(),
 token.key().as_ref(),
 ],
bump,
seeds::program = metadata::ID
 )]
token_metadata_account: UncheckedAccount<'info>,


/// CHECK: created in instruction
 #[account(
mut,
 seeds = [
 global_vault.key().as_ref(),
 token::spl_token::ID.as_ref(),
 token.key().as_ref(),
 ],
bump,
seeds::program = associated_token::ID
 )]
global_token_account: UncheckedAccount<'info>,


 #[account(address = system_program::ID)]
system_program: Program<'info, System>,


 #[account(address = Rent::id())]
rent: Sysvar<'info, Rent>,


 #[account(address = token::ID)]
token_program: Program<'info, Token>,


 #[account(address = associated_token::ID)]
associated_token_program: Program<'info, AssociatedToken>,


 #[account(address = metadata::ID)]
mpl_token_metadata_program: Program<'info, Metadata>,


// team wallet
/// CHECK: should be same with the address in the global_config
 #[account(
mut,
 constraint = global_config.team_wallet == team_wallet.key() @Market.funError::IncorrectAuthority
 )]
pub team_wallet: AccountInfo<'info>,


/// CHECK: ata of team wallet
 #[account(
mut,
 seeds = [
 team_wallet.key().as_ref(),
 anchor_spl::token::spl_token::ID.as_ref(),
 token.key().as_ref(),
 ],
bump,
seeds::program = anchor_spl::associated_token::ID
 )]
team_wallet_ata: AccountInfo<'info>,
}

Imports: Necessary modules and dependencies.

Launch Struct: Defines the accounts and programs required for the Launch instruction.

Process Method: Implements the logic for launching a token with a bonding curve. It:

* Validates input parameters.

* Initializes the bonding curve and token accounts.

* Mints tokens to the bonding curve and team wallet.

* Creates metadata for the token.

* Revokes mint authority.

* Emits a Launch Event.

The Launch struct and process method together handle the creation and configuration of a new token, including its bonding curve and associated metadata.

Last updated