Skip to content

Conversation

@ryanio
Copy link
Collaborator

@ryanio ryanio commented Oct 17, 2025

Summary

Fixes #1795

This PR modifies the fulfillOrder method to use transaction data directly from the OpenSea API's generateFulfillmentData endpoint. The transaction is encoded using ethers and sent directly, ensuring that collection offers (and trait offers) are fulfilled correctly with proper criterias automatically generated by the API.

Changes

  • Modified fulfillOrder to get transaction data from OpenSea API's generateFulfillmentData endpoint
  • Use ethers.Interface to encode the transaction calldata from the API's function signature and structured input data
  • Send the encoded transaction directly without using seaport-js for fulfillment
  • Removed deprecated parameters: recipientAddress, unitsToFill, and domain (these are now determined by the API)
  • Updated tests to reflect the new implementation
  • Updated type definitions to support the full API response structure

How it works

  1. Call OpenSea API generateFulfillmentData with order hash, account address, and optional asset details
  2. API returns structured transaction data including:
    • Function signature (e.g., fulfillAdvancedOrder(...))
    • Contract address to call
    • ETH value to send
    • Structured input data (e.g., advancedOrder, criteriaResolvers, recipient)
  3. Use ethers.Interface to encode the function call with the structured input data
  4. Send the encoded transaction directly

Why this approach?

The OpenSea API's generateFulfillmentData endpoint returns complete transaction data with all necessary parameters properly encoded. By using this data directly:

  1. Collection offers work correctly - The API automatically generates proper considerationCriteria when assetContractAddress and tokenId are provided
  2. All edge cases are handled - Offer protection, partial fills, and other complex scenarios are handled by the API
  3. Stays in sync with OpenSea - The SDK automatically benefits from API improvements and bug fixes

Breaking Changes

Removed parameters from fulfillOrder:

  • domain - Domain attribution is now included in the API transaction data

Test plan

  • All existing fulfillment tests pass
  • Tests updated to use new API transaction structure
  • Build passes without errors
  • Integration tests pass

🤖 Generated with Claude Code

ryanio and others added 8 commits October 17, 2025 17:42
Fixes #1795

Changes:
- Modified fulfillOrder to use transaction data from OpenSea API's
  generateFulfillmentData endpoint instead of using seaport-js
- This ensures that collection offers are fulfilled correctly with
  proper criterias automatically generated by the API
- Deprecated recipientAddress, unitsToFill, and domain parameters
  as these are now determined by the API transaction data
- Updated tests to reflect the new implementation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Removed recipientAddress, unitsToFill, and domain parameters
- These are now determined by the OpenSea API transaction data
- Updated public SDK method and internal FulfillmentManager
- Removed tests for deprecated parameters
- Updated documentation
- Encode transaction calldata using ethers.Interface with function signature
- Pass structured input_data values from API to encoded function
- Updated type definitions to support new API response structure
- Updated test mocks with proper function signatures and input data
- Use existing context.requireAccountIsAvailable check
- Simplify code by directly using context.signerOrProvider as Signer
- Order parameters correctly based on function name
- Handle fulfillAdvancedOrder, fulfillBasicOrder, and fulfillOrder
- Provide default values for optional parameters like fulfillerConduitKey
- Keep original input_data type with orders field only
- Use 'as any' type assertion to access dynamic fields
- Maintains backward compatibility
- Created union type with specific variants for each Seaport function
- fulfillAdvancedOrder: advancedOrder, criteriaResolvers, fulfillerConduitKey, recipient
- fulfillBasicOrder: basicOrderParameters
- fulfillOrder: order, fulfillerConduitKey, recipient
- Legacy: orders array for backward compatibility
- Added type guards in fulfillment code to narrow union type
- Removed 'as any' assertion - now fully typed
@BernardGeorge
Copy link

@ryanio When can this fix be merged?

@ryanio
Copy link
Collaborator Author

ryanio commented Oct 30, 2025

@BernardGeorge sorry had some pre-work that had to be done on the API side, this should be ready now will try to merge and publish now, just have to fix CI

- Add unitsToFill parameter to both listing and offer fulfillment
  - For listings: defaults to remaining quantity on API side
  - For offers: defaults to 1 on API side
- Add recipientAddress parameter to listing fulfillment only
  - Allows specifying NFT recipient when fulfilling listings
  - Not applicable for offers
- Update API layer to pass new parameters through payload functions
- Add test for recipientAddress parameter
- Update tests to verify unitsToFill behavior
- Bump version to 8.0.4
@ryanio ryanio merged commit 1ffeecf into main Oct 30, 2025
8 checks passed
@ryanio ryanio deleted the use-api-fulfill-tx branch October 30, 2025 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the sdk fulfillorder get error "You must supply the appropriate criterias for criteria based items"

3 participants