Skip to content

lfj-gg/sol-token-mill-v2-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sol-token-mill-v2-js-sdk

This package is not published on npm. To use it, run

bun add lfj-gg/sol-token-mill-v2-js-sdk

It provides easy to use functions for token creation (requires an API key) and swaps.

Create token

const sdk = new TokenMillSDK("https://api.mainnet-beta.solana.com");
const apiKey = process.env.API_KEY ?? "";
sdk.setApiKey(apiKey);
sdk.initializeAnchorWallet();

const tokenMetadata: TokenMetadata = {
  name: "My Token",
  symbol: "MYTK",
  imagePath: "Path to the icon image, PNG or JPEG, 5Mo maximum",
  description: "My custom description",
  socials: {
      discord: "https://discord.gg/mytoken",
      telegram: "https://t.me/mytoken",
      twitter: "https://twitter.com/mytoken",
      website: "https://mytoken.com",
    },
};

await sdk.createMarket(tokenMetadata);

// Optional swap parameters can be provided for the initial buy
await sdk.createMarket(tokenMetadata, {
  initialSwapParameters: {
    buyExactIn: { amountIn: new BN(1e9), minAmountOut: new BN(0) },
  },
});

Swap

const sdk = new TokenMillSDK("https://api.mainnet-beta.solana.com");
const apiKey = process.env.API_KEY ?? "";

// Either call sdk.initializeAnchorWallet() or directly provide the payer keypair 
// to any function of the SDK
const devKeypair = Keypair.generate();

await sdk.swap(
  {
    market: new PublicKey("11111111111111111111111111111111"),
    user: new PublicKey("22222222222222222222222222222222"),
  },
  { buyExactIn: { amountIn: new BN(1e9), minAmountOut: new BN(0) } },
  devKeypair
);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published