openOrder
The openOrder
function implements a common flow to open an order on a SolverNet inbox contract, by combining single-purpose functions:
- Validating the order, using
validateOrder
- Sending the order transaction, using
sendOrder
- 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
Prop | Type | Required | Description |
---|---|---|---|
client | Client | Yes | The viem client used to send the transaction. This client must have an account attached to it. |
inboxAddress | Address | Yes | The address of the inbox contract, retrieved using the getContracts function. |
order | Order | Yes | Order parameters |
pollinginterval | number | No | Polling interval in milliseconds, defaults to the client polling interval. |
environment | Environment | No | SolverNet 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,
})