🛤️Purchase an NFT with any token on any chain

Submit your intents and receive all possible solutions for the best execution route.

The Shogun SDK enables anyone to broadcast intents and receive optimal execution routes from a host of different liquidity venues. The SDK allows you to compose the intent lifecycle how you see fit. You can choose to handle the entire lifecycle through the SDK via direct execution or you just request quotes and handle execution yourself.

You can request the best route for a particular intent by utilizing the legoClient function.import { useShogunQuote } from '@shogun-sdk/one-shot';

// Example: Purchase an NFT using ETH
async function purchaseNFT() {
  try {
    const result = await legoClient.MagicEden.SwapForNFT({
      items: [{ 
        address: '0x7E0b0363804C6C79AAb9aB51850bF8F3D561f868', // NFT contract address
        tokenId: '42' // The NFT token ID you want to purchase
      }],
      token: { 
        address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', // WETH address
        decimals: 18, 
        chainId: 1  // Ethereum mainnet
      },
      userAddress: '0x742d35Cc6634C0532925a3b844Bc454e4438f44e' // Your wallet address
    });

    if (result.status) {
      console.log('Success! Transaction steps:', result.data.steps);
      // Execute the transaction steps...
    } else {
      console.error('Failed to fetch data:', result.error);
    }
  } catch (error) {
    console.error('Error:', error);
  }
}

Available parameters

The following parameters enable you to customize your Lego request:

Parameter
Description
Type

items

An array of nfts that you want to buy

Array of Items

token

The token you want to buy

Number (required)

userAddress

Wallet address initiating the transaction.

String (required)

🚆Executing Transactions

Last updated