This action is used to accept a valid offer/bid.
You can supply an object of parameters listed below:
Parameter | Description | Required | Example |
---|---|---|---|
items | An 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" } |
signer | A valid WalletClient from viem. | true | Refer to viem's documentation on WalletClients_ |
onProgress | Callback 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) } |
expectedPrice | Token price used to prevent to protect buyer from price moves. Can either be a single number or a map of currency contract address to a number. | false | 1.543 or { "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": 1.5, "0x0000000000000000000000000000000000000000": 1.1 } |
precheck | A 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. | false | false |
options | Supports all of the parameters allowed in the execute sell api | false | { source: 'opensea.io' ... } |
Example
import { getClient, Execute } from "@reservoir0x/reservoir-sdk";
import { createWalletClient, http } from 'viem'
...
address = "0x8ba1f109551bD432803012645Ac136ddd6000000"
signer = createWalletClient({
account: address,
transport: http()
})
getClient()?.actions.acceptOffer({
items: [{
token: "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d:1",
quantity: 1
}],
signer,
onProgress: (steps: Execute['steps'], path: Execute['path']) => {
console.log(steps)
}
})