Create a Token
Example code that would create the a token and buy .1 sol worth for the dev
from solana.rpc.api import Client
from solders.keypair import Keypair
from solders.keypair import Keypair
import solcoin.create_tokens as create
PUBLIC_KEY = "your_account_pubkey_string" # ex:G3tmXiWmgnhhjb4N12YK7QgmaqtRaCRaL6i4nx2ueKwr
SLIPPAGE_PERCENT = 20
PRIORITY_FEE = .00001
tokensOrSolAmount = .1 # how much you want to buy (initial dev buy)
tokensOrSol = 'sol' # 'token' or 'sol'
client = Client("your_RPC_url") # ex:https://api.mainnet-beta.solana.com
# generates a random mint keypair
mint_keypair = Keypair()
mint_pubkey = mint_keypair.pubkey()
# the token mint's pubkey
print(mint_pubkey)
private_key_base58 = "private_key_base58_string" # your base58 private key string
payer_keypair = Keypair.from_base58_string(private_key_base58)
# metadata about your new token
form_data = {
'name': "token name",
'symbol': "tokenSymbol",
'description': "description of token",
'twitter': 'https://google.com',
'telegram': 'https://google.com',
'website': 'https://google.com',
'showName': 'true'
}
photopath = r"path\to\cover\photo\example.png"
sig, status = create.create_token(mint_pubkey, client, tokensOrSolAmount, tokensOrSol, SLIPPAGE_PERCENT, PUBLIC_KEY, payer_keypair, PRIORITY_FEE, form_data, photopath, mint_keypair)
print(sig)
print(status)
PUBLIC_KEY = The public key of the account you are using to create and purchase the tokens, make sure this account has enough sol in it to cover fees and pay for rent
SLIPPAGE_Percent = % price slippage for transaction to still proceed
PRIORITY_FEE = fee paid divided among 150k compute units
TokensOrSolAmount = the initial dev buy amount of tokens or sol; depends on the value of tokensOrSol
TokensOrSol = what unit you are buying either 'token' or 'sol'
TOKEN_MINT = the mint pubkey of the token you are trying to purchase
client = the rpc client you are using, replace the rpc_url with your rpc provider's url
RPC Providers: https://solana.com/rpc
private_key_base58 = the private key string of the account you are using to create and purchase the tokens.
Last updated