// 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,
})