Something.cool
  • Getting started
    • Why Something.cool?
    • 1st stage - Bonding curve
    • 2nd stage - CoolDEX trading
  • Zero-fee coins
    • What is Zero-fee coin?
    • How to launch Zero-fee coin
  • Community coins
    • What is Community coin?
    • Community contribution / How it works?
      • Holders
      • Liquidity providers
      • Burning
    • How to launch Сommunity coin
  • Features
    • Coin Explore
      • New Pairs
      • Coin Vision
    • Spaces
    • Rewards
  • Community
    • Referral program
    • X
    • Media kit
  • Developer Resources
  • Platform Architecture
    • Technical Introduction
    • Overview
    • Components
  • SC Bonding Curve
    • Overview
    • Functions
      • Create Token
      • Buy Token
      • Sell Token
      • Migrate
      • Admin Set Properties
    • Price Calculation
    • Fees
  • CoolDEX
    • Overview
    • Functions
      • Initialize Pool
      • Swap Base In
      • Swap Base Out
      • Deposit
      • Withdraw
      • Withdraw PnL
    • Price Calculation
    • Fees
  • Token Types
    • Token Types
  • Migration Process
    • Migration Process
  • Rewards Claiming
    • Overview
    • Authentication
    • Endpoints
    • Errors
    • Example
  • Reference
    • SC Bonding Curve IDL
    • CoolDEX IDL
    • Log Structure
    • DEVNET EXAMPLES
  • INTERNAL API
    • Overview
    • Register
  • Example: Registering a User via Internal API (JavaScript)
Powered by GitBook
On this page
  • Instruction Index
  • Instruction
  • Parameters
  • Account Setup
  • Function Logic
  • Notes
  • Example Usage
  1. SC Bonding Curve
  2. Functions

Create Token

Creates a new token with a bonding curve for initial liquidity.

Instruction Index

1

Instruction

SCBondingCurveInstruction::CreateToken {
    pda_token_nonce: u8,
    uri: String,
    name: String,
    symbol: String,
    after_migration_fee: u16,
    after_migration_burn_bp: u16,
    after_migration_holders_bp: u16,
    after_migration_lp_bp: u16,
    logging_account_bump: u8,
}

Parameters

Parameter
Type
Description

pda_token_nonce

u8

Nonce for generating the token owner PDA

uri

String

Token metadata URI

name

String

Token name

symbol

String

Token symbol

after_migration_fee

u16

Fee percentage (in basis points) after migration (valid values: 0, 25, 50, 100, 200, 500)

after_migration_burn_bp

u16

Percentage of fees allocated to burning (in basis points)

after_migration_holders_bp

u16

Percentage of fees allocated to token holders (in basis points)

after_migration_lp_bp

u16

Percentage of fees allocated to liquidity providers (in basis points)

logging_account_bump

u8

Bump for the logging authority PDA

Account Setup

#
Account
Description
Derivation

1

Properties account

Platform configuration

[Buffer.from("settings")]

2

Payer account

Transaction signer (User wallet)

-

3

Token program

SPL Token program

TOKEN_PROGRAM_ID

4

System program

System program

SystemProgram.programId

5

Associated token account program

ATA program

ASSOCIATED_TOKEN_PROGRAM_ID

6

Token mint

New token mint

Generated keypair

7

Token owner PDA

Bonding curve account

[Buffer.from("token_owner"), mint.toBuffer(), [nonce]]

8

Token owner token account

Token account for PDA

getAssociatedTokenAddress(mint, ownerPDA, true)

9

Metaplex token metadata program

Metadata program

metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s

10

Metaplex token metadata account

Metadata account

["metadata", metaplexProgram.toBuffer(), mint.toBuffer()]

11

Post migration CC* WSOL storage

SOL storage

PublicKey.createWithSeed(mint, "w", TOKEN_PROGRAM_ID)

12

Post migration CC* token storage

Token storage

PublicKey.createWithSeed(mint, "t", TOKEN_PROGRAM_ID)

13

Rent sysvar

Rent program

SYSVAR_RENT_PUBKEY

14

Native mint

WSOL mint

NATIVE_MINT

15

CoolDEX owner

Platform owner

Fixed address (see Reference section)

16

Program account

SC Bonding Curve program

SC Bonding Curve program ID

17

Log authority account

For structured logs

[Buffer.from("logging_authority")]

*CC - Community Contribution

Function Logic

  1. Validates that fee components sum to 10000 basis points (100%)

  2. Verifies that the after_migration_fee is one of the allowed values (0, 25, 50, 100, 200, 500)

  3. Creates the token mint account

  4. Creates the bonding curve data account

  5. Initializes the bonding curve with virtual SOL and token amounts

  6. Mints the initial token supply to the bonding curve

  7. Creates and initializes the token metadata

  8. Creates post-migration token and SOL storage accounts

  9. Records creation data in logs

Notes

  • The initial mint amount is set to 10,000,000,000.000000 tokens with 6 decimal places

  • The token must have a valid name, symbol, and metadata URI

  • The fee parameters determine how fees will be distributed after migration to the DEX

  • The bonding curve is initialized with virtual SOL and token amounts to establish the initial price

Example Usage

// Generate a new mint
const mintKeypair = Keypair.generate()

// Derive PDAs and other accounts
const [propertiesAccount] = PublicKey.findProgramAddressSync(
  [Buffer.from("settings")],
  SC_BONDING_CURVE_PROGRAM_ID
)

const [tokenOwnerPDA, pdaTokenNonce] = PublicKey.findProgramAddressSync(
  [Buffer.from("token_owner"), mintKeypair.publicKey.toBuffer()],
  SC_BONDING_CURVE_PROGRAM_ID
)

const [logAuthority, logAuthorityBump] = PublicKey.findProgramAddressSync(
  [Buffer.from("logging_authority")],
  SC_BONDING_CURVE_PROGRAM_ID
)

// Get token accounts
const ownerTokenAccount = getAssociatedTokenAddressSync(
  mintKeypair.publicKey,
  tokenOwnerPDA,
  true
)

// Create metadata account
const [metadataAccount] = PublicKey.findProgramAddressSync(
  [
    Buffer.from("metadata"),
    METAPLEX_PROGRAM_ID.toBuffer(),
    mintKeypair.publicKey.toBuffer(),
  ],
  METAPLEX_PROGRAM_ID
)

// Create Community Contribution storage accounts
const cultStorageWsol = await PublicKey.createWithSeed(
  mintKeypair.publicKey,
  "w",
  TOKEN_PROGRAM_ID
)

const cultStorageToken = await PublicKey.createWithSeed(
  mintKeypair.publicKey,
  "t",
  TOKEN_PROGRAM_ID
)

const data = Buffer.alloc(1000)
let offset = 0

// Selector = 1, create token
data.writeUint8(1, offset)
offset += 1

// Name, Symbol or URI can not be longer than 255
data.writeUint8(curveBump, offset)
offset += 1
data.writeUint8(urlBuffer.length, offset)
offset += 1
data.write(url, offset, "utf-8")
offset += urlBuffer.length
data.writeUint8(nameBuffer.length, offset)
offset += 1
data.write(name, offset, "utf-8")
offset += nameBuffer.length
data.writeUint8(symbolBuffer.length, offset)
offset += 1
data.write(symbol, offset, "utf-8")
offset += symbolBuffer.length

data.writeUint16LE(fee, offset) // fee, 100 means 1%
offset += 2
data.writeUint16LE(burnFee, offset) // share to burn out of fee, 100 means 1%
offset += 2
data.writeUint16LE(holdersFee, offset) // share to holders out of fee,, 100 means 1%
offset += 2
data.writeUint16LE(lpFee, offset) // share to lp out of fee,, 100 means 1%
offset += 2
data.writeUint8(logAuthorityBump, offset)
offset += 1

const createTokenIx = new TransactionInstruction({
  programId: SC_BONDING_CURVE_PROGRAM_ID,
  keys: [
    { pubkey: propertiesAccount, isSigner: false, isWritable: true },
    { pubkey: wallet.publicKey, isSigner: true, isWritable: true },
    { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
    { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
    { pubkey: ASSOCIATED_TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
    { pubkey: mintKeypair.publicKey, isSigner: true, isWritable: true },
    { pubkey: tokenOwnerPDA, isSigner: false, isWritable: true },
    { pubkey: ownerTokenAccount, isSigner: false, isWritable: true },
    { pubkey: METAPLEX_PROGRAM_ID, isSigner: false, isWritable: false },
    { pubkey: metadataAccount, isSigner: false, isWritable: true },
    { pubkey: cultStorageWsol, isSigner: false, isWritable: true },
    { pubkey: cultStorageToken, isSigner: false, isWritable: true },
    { pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
    { pubkey: NATIVE_MINT, isSigner: false, isWritable: false },
    { pubkey: COOLDEX_OWNER, isSigner: false, isWritable: false },
    { pubkey: SC_BONDING_CURVE_PROGRAM_ID, isSigner: false, isWritable: false },
    { pubkey: logAuthority, isSigner: false, isWritable: false },
  ],
  data: data,
})
PreviousFunctionsNextBuy Token

Last updated 2 months ago