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

使用ccip-js调用getTransferStatus遇Router合约eth_call内部错误(Viem+Cloudflare RPC)

CCIP消息转账状态查询失败:RPC内部错误问题

我尝试使用ccip-js获取CCIP消息转账状态,从CSV文件加载CCIP messageId后调用以下代码:

await ccipClient.getTransferStatus({
  messageId,
  client: publicClient,
  destinationRouterAddress: "0x881e3A65B4d4a04dD529061dd0071cf975F58bCD",
  sourceChainSelector: "5009297550715157269",
});

但每次调用都因RPC内部错误失败,日志显示调用Router合约的getOffRamps()方法时,Cloudflare RPC返回内部错误。

错误日志

Error fetching status for 0xcc7a5ee8495593e53ab4197b2d030da801607a8a116ae02c68a13d168f67f208: An internal error was received.

URL: https://cloudflare-eth.com
Request body: {"method":"eth_call","params":[{"data":"0xa40e69c7","to":"0x881e3A65B4d4a04dD529061dd0071cf975F58bCD"},"latest"]}

Raw Call Arguments:
  to:    0x881e3A65B4d4a04dD529061dd0071cf975F58bCD
  data:  0xa40e69c7

Contract Call:
  address:   0x881e3A65B4d4a04dD529061dd0071cf975F58bCD
  function:  getOffRamps()

Details: Internal error
Version: viem@1.21.0

本次调用的messageId为0xcc7a5ee8495593e53ab4197b2d030da801607a8a116ae02c68a13d168f67f208,我曾尝试使用viem v2,但因报错降级到viem v1。

完整脚本

import * as CCIP from '@chainlink/ccip-js'
import { createPublicClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { ethers } from 'ethers'
import fs from 'fs'
import path from 'path'
import { fileURLToPath } from 'url'
import pLimit from 'p-limit'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const CSV_PATH = path.join(__dirname, 'messageIds.csv')

const publicClient = createPublicClient({
  chain: mainnet,
  transport: http(),
})

const ccipClient = CCIP.createClient()

function loadFromCsv(filepath: string): string[] {
  if (!fs.existsSync(filepath)) return []
  const fileContent = fs.readFileSync(filepath, 'utf-8')
  return fileContent.split('\n').filter(l => l && l !== 'messageId')
}

async function checkStatusSequential(messageIds: string[]) {
  for (const id of messageIds) {
    try {
      const status = await ccipClient.getTransferStatus({
        messageId: id as `0x${string}`,
        client: publicClient,
        destinationRouterAddress: "0x881e3A65B4d4a04dD529061dd0071cf975F58bCD",
        sourceChainSelector: "5009297550715157269",
      })
      console.log(`Message ID: ${id} -> Status: ${status}`)
    } catch (err: any) {
      console.error(`Error fetching status for ${id}:`, err.message)
    }
  }
}

async function main() {
  const loadedIds = loadFromCsv(CSV_PATH)
  await checkStatusSequential(loadedIds)
}

main().catch(console.error)

依赖

"devDependencies": {
    "@chainlink/ccip-js": "^0.2.6",
    "@types/node": "^20.19.25",
    "dotenv": "^16.6.1",
    "ethers": "^6.15.0",
    "p-limit": "^5.0.0",
    "tsx": "^4.20.6",
    "typescript": "^5.9.3",
    "viem": "^1.21.0"
  }

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.12 00:05:17