Gold Logo

How It Works

Program Flow

The Gold Digger Factory Program follows a specific flow for each operation, ensuring security, efficiency, and proper integration with the Solana blockchain.

NFT Minting Process

When a user mints an NFT through the Gold Digger Factory Program, the following steps occur:

  1. Initialization: The client application calls the mint_nft instruction with the required parameters (URI, title, etc.).
  2. Account Creation: The program creates a new mint account for the NFT.
  3. Metadata Creation: The program creates a metadata account using Metaplex's Token Metadata program.
  4. Fee Collection: A 5% fee is automatically calculated and transferred to the fee vault.
  5. Token Minting: The program mints exactly one token to the user's wallet.
  6. Finalization: The program updates all necessary accounts and returns the result to the client.
// Simplified minting process
pub fn mint_nft(ctx: Context<MintNft>, uri: String, title: String) -> Result<()> {
    // 1. Create Mint Account
    let mint = &ctx.accounts.mint;
    
    // 2. Create Metadata Account
    let metadata_account = create_metadata_account(mint.clone(), uri.clone(), title.clone())?;
    
    // 3. Calculate and collect fee
    let fee = calculate_fee(ctx.accounts.payer.lamports())?;
    collect_fee(ctx.accounts.payer.to_account_info(), fee)?;
    
    // 4. Mint token to user
    token::mint_to(
        CpiContext::new(
            ctx.accounts.token_program.to_account_info(),
            MintTo {
                mint: ctx.accounts.mint.to_account_info(),
                to: ctx.accounts.token_account.to_account_info(),
                authority: ctx.accounts.payer.to_account_info(),
            },
        ),
        1,
    )?;
    
    // 5. Update metadata
    update_metadata(metadata_account, uri, title)?;
    
    Ok(())
}

Staking Mechanism

The staking mechanism in the Gold Digger Factory Program works as follows:

  1. Pool Creation: An admin initializes a staking pool with specific reward parameters.
  2. NFT Staking: Users stake their NFTs by transferring them to the program's custody.
  3. Reward Calculation: The program tracks staking duration and calculates rewards based on the pool's reward rate.
  4. Reward Distribution: Users can claim rewards at any time, which are transferred to their wallet.
  5. Unstaking: Users can unstake their NFTs, returning them to their wallet and finalizing reward calculations.
// Simplified staking process
pub fn stake_nft(ctx: Context<StakeNft>, nft: Pubkey) -> Result<()> {
    // 1. Verify NFT ownership
    verify_ownership(ctx.accounts.user.key(), nft)?;
    
    // 2. Transfer NFT to program custody
    transfer_nft_to_program(nft, ctx.accounts.program_authority.key())?;
    
    // 3. Record staking information
    let pool = &mut ctx.accounts.pool;
    pool.staked_nfts.push(StakedNft {
        mint: nft,
        owner: ctx.accounts.user.key(),
        staked_at: Clock::get()?.unix_timestamp,
    });
    
    // 4. Initialize reward tracking
    initialize_rewards(ctx.accounts.user.key(), nft, pool.reward_rate)?;
    
    Ok(())
}

Collection Management

The Gold Digger Factory Program allows for the creation and management of multiple NFT collections:

  1. Collection Creation: An admin creates a new collection with specific parameters.
  2. Collection Configuration: The admin sets collection-specific settings like royalties and metadata.
  3. NFT Assignment: When minting, NFTs can be assigned to specific collections.
  4. Collection Verification: The program verifies collection membership for operations.
  5. Collection Statistics: The program tracks and provides statistics for each collection.