πŸ‡Wallet providers - Request an order

How to create an order for wallet providers

When working with wallet providers like MetaMask, you need to handle the connection and signing process differently. Here are examples for integrating with MetaMask and other wallet providers.

EVM Chains

const order = await Order.create({
  user: userAddress,
  sourceChainId: ChainID.Arbitrum,
  sourceTokenAddress: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', // USDT
  sourceTokenAmount: BigInt(10_000_000), // 10 USDT
  destinationChainId: ChainID.Solana,
  destinationTokenAddress: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
  destinationTokenMinAmount: BigInt(9_500_000),
  destinationAddress: '3Kiz4oBXpR9YuPNsVfvE5XnNzgwjrM9m2CbRzyyEVkpQ',
  minStablecoinAmount: BigInt(9_800_000),
  deadline: Math.floor(Date.now() / 1000) + 3600,
});

// Sign the order with MetaMask
const { orderTypedData, nonce } = await getEvmOrderTypedData(order); // You'll need to implement this

// Prompt the user to sign typed data using your wallet provider (wagmi, etc...)
const signature = await signer.signTypedData( // '0x...'
  orderTypedData.domain,
  orderTypedData.types,
  orderTypedData.message
);

// Once generated the signature by the wallet provider
let response = await sendEvmRequest({ order, signature, nonce });

Solana

Sui

Last updated