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

使用Keplr向Injective测试网合约发交易失败,报‘invalid mode’错误

解决Keplr调用Injective合约交易"invalid mode"报错问题
  • 报错原因:keplr.sendTx的第三个参数广播模式需传入字符串类型,你当前使用的枚举值BroadcastMode.Sync无法被Keplr正确识别,从而触发"invalid mode"错误。
  • 修复方法:将BroadcastMode.Sync替换为字符串格式的"sync",其他可选广播模式为"async"或"block",按需选择。

修改后的代码示例:

const { txRaw } = createTransaction({
  pubKey,
  chainId,
  fee: DEFAULT_STD_FEE,
  message: msg,
  sequence: accountDetails.sequence,
  timeoutHeight: timeoutHeight.toNumber(),
  accountNumber: baseAccount.accountNumber,
})

const result = await keplr.sendTx(
  chainId,
  CosmosTxV1Beta1Tx.TxRaw.encode(txRaw).finish(),
  "sync", // 替换为字符串格式的广播模式
)
  • 额外检查点:确认DEFAULT_STD_FEE符合Injective测试网的gas额度要求;同时核实sequence和accountNumber为账户最新值,过期的序列值也会导致交易执行失败。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 16:52:33