Skip to main content
Glama
offer.ts1.96 kB
import { Agent } from '../../agent'; import { OfferParams, TransactionResponse } from '../../types'; export async function createOffer(agent: Agent, params: OfferParams): Promise<TransactionResponse> { try { const offerCreate: any = { TransactionType: 'OfferCreate', Account: agent.walletAddress, TakerGets: params.takerGets, TakerPays: params.takerPays, ...(params.expiration && { Expiration: params.expiration }), ...(params.offerSequence && { OfferSequence: params.offerSequence }) }; const prepared = await agent.client.autofill(offerCreate); const signed = agent.wallet.sign(prepared); const result: any = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || 'unknown', result: result.result }; } catch (error) { return { status: 'error', message: error instanceof Error ? error.message : 'Unknown error occurred' }; } } export async function cancelOffer(agent: Agent, offerSequence: number): Promise<TransactionResponse> { try { const offerCancel: any = { TransactionType: 'OfferCancel', Account: agent.walletAddress, OfferSequence: offerSequence }; const prepared = await agent.client.autofill(offerCancel); const signed = agent.wallet.sign(prepared); const result: any = await agent.client.submitAndWait(signed.tx_blob); return { hash: result.result.hash, status: result.result.meta?.TransactionResult || 'unknown', result: result.result }; } catch (error) { return { status: 'error', message: error instanceof Error ? error.message : 'Unknown error occurred' }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tamago-labs/xrpl-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server