SolanaPortal
  • ✨Welcome to SolanaPortal
  • Getting Started
    • ⭐Why SolanaPortal?
    • πŸ“–Guide
    • πŸ—ΊοΈBest Practices
    • ❓FAQ
  • API Documentation
    • Swapping
      • Swapping with Node.js
      • Swapping with Python
      • Swapping with Rust
    • Token Creation
      • Pump.fun Token
      • Standard Token
  • Market Creation
  • ‼️Troubleshooting
  • Support
Powered by GitBook
On this page
  • Introduction
  • API Endpoint - Market Creation
  • Required Parameters for Market Creation
  • Parameter Explanations
  • 1. wallet_address
  • 2. mint
  • Example Market Creation Request
  • Response Handling
  • Transaction Signing and Submission
  • Submitting to Jito Bundle Service
  • Verifying Transaction Success
  • Important Notes

Market Creation

Introduction

Market Creation via SolanaPortal allows users to create custom trading markets for tokens on the Solana blockchain. Creating a market establishes the necessary infrastructure for token trading, including order books and liquidity pools. This process is essential for tokens that need to become tradable on decentralized exchanges. After standard token creation, market creation specifically focuses on establishing the trading environment for an existing token. This method is ideal for token creators who want to enable trading for their tokens and provide liquidity opportunities for traders.

API Endpoint - Market Creation

http://localhost:3000/api/create/market

This endpoint accepts JSON data and requires specific parameters to create a market successfully.

Required Parameters for Market Creation

Each parameter in the Market Creation API plays a vital role in defining how your token market functions on the Solana blockchain. Below is a detailed breakdown of all required parameters.

Parameter
Description

wallet_address

string

βœ…

The public key of the wallet that will own the newly created market

mint

integer

βœ…

The mint address of the token for which the market will be created

Parameter Explanations

1. wallet_address

The public key of the wallet that will own and manage the newly created market.

Example:

wallet_address: wallet.publicKey.toBase58(),

Ensure this is your Solana wallet address, as this wallet will have administrative rights over the market. This wallet will be responsible for signing the market creation transactions and will be associated as the market authority.

2. mint

The mint address of the token for which you want to create a market. This must be an existing token on the Solana blockchain.

Example:

mint: "token_mint_address_here",

This address uniquely identifies your token on the Solana blockchain. Make sure to use the correct mint address, as this cannot be changed after market creation.

The market will be created for the token based on the mint address provided.

Example Market Creation Request

javascriptconst param = {
  wallet_address: wallet.publicKey.toBase58(),
  mint: "4cmzTVQFWXFmiwVbuVNrGgfDFNrSqXweyvZPUUWWWvi3",
};

const url = "http://localhost:3000/api/create/market";
const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(param),
});

Response Handling

After submitting your market creation request, you'll receive a response containing:

  1. market_id: A unique identifier for your newly created market

  2. serializedTxns: An array of serialized transactions that need to be signed and submitted

javascriptif (response.status === 200) {
  // successfully generated transaction
  const data = await response.json();
  const { market_id, serializedTxns } = data;
  console.log("market id:", market_id);
  
  // Process the transactions...
}

Transaction Signing and Submission

The market creation process requires signing and submitting multiple transactions. Here's how to handle them:

javascriptconst encodedSignedTxns = [];
const signatures = [];

for (let i = 0; i < serializedTxns.length; i++) {
  const txnBuffer = Buffer.from(serializedTxns[i], "base64");
  const txn = VersionedTransaction.deserialize(txnBuffer);
  txn.sign([wallet]);
  signatures.push(bs58.encode(txn.signatures[0]));
  const signedTxnBuffer = txn.serialize();
  encodedSignedTxns.push(bs58.encode(signedTxnBuffer));
}

Submitting to Jito Bundle Service

For optimal execution, the signed transactions can be submitted as a bundle to Jito's bundle service:

javascriptconst jitoResponse = await fetch(
  `https://tokyo.mainnet.block-engine.jito.wtf/api/v1/bundles`,
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: 1,
      method: "sendBundle",
      params: [encodedSignedTxns],
    }),
  }
);

Verifying Transaction Success

After submitting the bundle, you can verify the transaction status:

javascriptif (jitoResponse.status === 200) {
  for (let i = 0; i < signatures.length; i++) {
    console.log(
      `Transaction ${i}: https://solscan.io/tx/${signatures[i]}`
    );
  }
} else {
  console.log(
    "bundle failed, please check the parameters",
    jitoResponse
  );
}

Important Notes

  • Transactions are bundled and sent to Jito for optimal execution and to ensure all transactions are processed in the correct order.

  • Market creation is a one-time process for each token - once created, the market can be used indefinitely.

  • The market_id returned in the response is crucial for future interactions with this market.

  • Market creation is a multi-step process that requires several on-chain transactions.

  • The wallet creating the market must have sufficient SOL to cover transaction fees.

  • After market creation, you may need to provide initial liquidity to enable trading.

  • Always verify transaction success by checking the provided Solscan links.

Next Steps

To learn how to implement complete Market Creation programmatically, visit the language-specific guides:

PreviousStandard TokenNextTroubleshooting

Last updated 3 months ago

Swapping with Node.js
Swapping with Python
Swapping with Rust