Skip to content

openOrder

The openOrder function implements a common flow to open an order on a SolverNet inbox contract, by combining single-purpose functions:

  1. Validating the order, using validateOrder
  2. Sending the order transaction, using sendOrder
  3. Waiting for the order to be open on the blockchain, using waitForOrderOpen

Usage

import { openOrder } from '@omni-network/core'

import { openOrder } from '@omni-network/core'
 
const resolvedOrder = await openOrder({
  // ... params
});

Parameters

PropTypeRequiredDescription
clientClientYesThe viem client used to send the transaction. This client must have an account attached to it.
inboxAddressAddressYesThe address of the inbox contract, retrieved using the getContracts function.
orderOrderYesOrder parameters
pollingintervalnumberNoPolling interval in milliseconds, defaults to the client polling interval.
environmentEnvironmentNoSolverNet environment to use, either mainnet (default) or testnet.

Return

openOrder returns the Promise of the created transaction hash as a ResolvedOrder object.

Example

import { getContracts, openOrder } from '@omni-network/core'
 
const orderParams = {...}
 
const contracts = await getContracts()
const resolvedOrder = await openOrder({
  client: viemWalletClient,
  inboxAddress: contracts.inbox,
  order: orderParams,
})