Skip to content

> 按照example中的例子,使用sdk进行evm swap兑换USDC时,如果wallet中已经有一些USDC,则swap正常,反之,会出现revert错误,且没有具体原因。 #78

@yumbo160480

Description

@yumbo160480

按照example中的例子,使用sdk进行evm swap兑换USDC时,如果wallet中已经有一些USDC,则swap正常,反之,会出现revert错误,且没有具体原因。

参数:

params {
  chainId: '56',
  fromTokenAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
  toTokenAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
  amount: '1000000000000000',
  slippage: '0.005',
  userWalletAddress: '0xxxxxxxx'
}

错误:

Swap execution failed: TransactionRevertInstructionError: Transaction has been reverted by the EVM
    at /Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/src/utils/get_transaction_error.ts:84:11
    at Generator.next (<anonymous>)
    at /Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:24:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:20:12)
    at getTransactionError (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:33:12)
    at SendTxHelper.<anonymous> (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/src/utils/send_tx_helper.ts:140:36)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/send_tx_helper.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:105:5) {
  cause: undefined,
  reason: 'execution reverted',
  signature: undefined,
  receipt: undefined,
  data: undefined,
  code: 402
}
[Nest] 9321  - 2025/05/08 19:47:13   ERROR [ExceptionsHandler] Transaction has been reverted by the EVM
TransactionRevertInstructionError: Transaction has been reverted by the EVM
    at /Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/src/utils/get_transaction_error.ts:84:11
    at Generator.next (<anonymous>)
    at /Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:24:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:20:12)
    at getTransactionError (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/get_transaction_error.js:33:12)
    at SendTxHelper.<anonymous> (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/src/utils/send_tx_helper.ts:140:36)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/alvinyao/Projects/okx-dex-grpc/node_modules/.pnpm/web3-eth@4.11.1_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.24.4/node_modules/web3-eth/lib/commonjs/utils/send_tx_helper.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

Originally posted by @yumbo160480 in okx/okx-dex-sdk#3 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions