You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用OpenSea Seaport-js SDK创建NFT购买订单执行报错求助

Seaport-js调用executeAllActions()触发地址未定义错误的排查

使用OpenSea Seaport-js SDK创建NFT购买订单时,seaport.createOrder()可正常执行,但调用executeAllActions()时抛出ethers.js错误:

Error: invalid address (argument="address", value=undefined, code=INVALID_ARGUMENT, version=address/5.7.0)

无法定位具体未定义的地址,以下是几个明显的疏漏点及排查方向:

排查要点

  • 确认walletAddress变量有效性:代码中两次用到walletAddress(createOrder的第二个参数、consideration的recipient字段),如果该变量未正确赋值(比如未从signer获取、赋值前未校验),会直接触发地址未定义错误。建议在调用前添加日志输出确认:
    console.log('walletAddress:', walletAddress);
    
  • Offer条目缺失itemType定义:你的offer是WETH(ERC20资产),但未指定itemType: ItemType.ERC20。Seaport SDK需要明确资产类型才能正确解析订单参数,缺失该字段可能导致内部处理时出现地址相关的参数异常。
  • 检查Seaport实例的signer初始化:如果创建Seaport实例时传入的signer未正确初始化(比如signer地址为空、未连接到钱包),执行executeAllActions()时会因签名环节的地址问题抛出错误。

修改后的示例代码

补全offer的itemType字段,并确保walletAddress有效:

const { executeAllActions } = await seaport.createOrder(
  {
    offer: [
      {
        itemType: ItemType.ERC20, // 新增ERC20类型声明
        amount: parseEther(ethAmount).toString(),
        // WETH on goerli
        token: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
      },
    ],
    consideration: [
      {
        itemType: ItemType.ERC721,
        token: "0xd5835369d4f691094d7509296cfc4da19efe4618",
        identifier: "10474",
        recipient: walletAddress,
      },
    ],
  },
  walletAddress
);
const order = await executeAllActions();

内容的提问来源于stack exchange,提问作者toekneema

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 02:55:13