acceptOffer

This action is used to accept a valid offer/bid.

You can supply an object of parameters listed below:

ParameterDescriptionRequiredExample
itemsAn array of objects representing orders to be purchased. Refer to the the execute sell api for a full list of parameters.true{ token:"0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1" }
walletA valid WalletClient from viem or a ReservoirWallet generated from an adapter. Learn more about adapters.trueRefer to viem's documentation on WalletClients_
onProgressCallback to update UI state as execution progresses. Can also be used to get the transaction hash for a given step item.true(steps, path) => { console.log(steps) }
expectedPriceToken price data used to protect buyer from price moves. Pass an object where the keys represent the currency and the value details the amount or/and raw amount with currency details. The raw amount will be more precise.false{ "0x0000000000000000000000000000000000000000": { amount: 10, raw: 10000000000000000000 currencyAddress: "0x0000000000000000000000000000000000000000", currencyDecimals: 18 } }
precheckA boolean indicating whether to just get back the steps/path and not to execute them. This is useful for checking if marketplace approval is required before iterating over the steps.falsefalse
optionsSupports all of the parameters allowed in the execute sell apifalse{ source: 'opensea.io' ... }
chainIdOverride the current active chainfalse1
gasString of the gas provided for the transaction execution. Unused gas will be returned.false"1000000000000000"

Example

import { getClient, Execute } from "@reservoir0x/reservoir-sdk";
import { createWalletClient, http } from 'viem'

...

address = "0x8ba1f109551bD432803012645Ac136ddd6000000"
wallet = createWalletClient({
  account: address,
  transport: http()
})

getClient()?.actions.acceptOffer({
  items: [{  
      token:  "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1",
      quantity: 1
  }],
  wallet,
  onProgress: (steps: Execute['steps'], path: Execute['path']) => {
    console.log(steps)
  }
})

Notes

  • expectedPrice - A feature that protects the seller when the price changes drastically in a less desirable direction. There’s a small threshold in which it’s ok for it to go down but once it’s crossed the SDK prevents the transaction from being submitted. This check is hardcoded into the SDK and occurs before the transaction hits the blockchain. The price is not inclusive of fees. To get the offer price you can use the tokens api or the useTokens hook.