0x

在 ropsten 上恢復交易

  • March 22, 2022

我試圖將 ETH 兌換成 DAI,但出現錯誤: https ://ropsten.etherscan.io/tx/0x19d2c3e8cd6bb1d4fa2da99f0a47de1c616b4d091f37d15f0a705ac784edb65e 我做錯了什麼?我試圖將其與工作交易進行比較

要求:

buyToken: 0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d
sellToken: 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
sellAmount: 10000000000000000
takeAddress: 0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded
slippagePercentage: 0.027000000000000003
skipValidation: true

回复:

{
   "chainId": 3,
   "price": "4241.8966555520202953",
   "guaranteedPrice": "4127.3654458521157473",
   "estimatedPriceImpact": "0",
   "to": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
   "data": "0x415565b0000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000023cc97a0d865eff6100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000460000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000040000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c778417e063141139fce010982780140aa0cd5ab000000000000000000000000c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002a0000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000012556e6973776170563300000000000000000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000023cc97a0d865eff61000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000e592427a0aece92de3edee1f18e0157c058615640000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002bc778417e063141139fce010982780140aa0cd5ab000bb8c715abcd34c8ed9ebbf95990e0c43401fbbc122d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c778417e063141139fce010982780140aa0cd5ab000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0000000000000000000000000000000000000000000000000000000000000000869584cd000000000000000000000000100000000000000000000000000000000000001100000000000000000000000000000000000000000000006aa766f2eb623a0341",
   "value": "10000000000000000",
   "gas": "149965",
   "estimatedGas": "149965",
   "gasPrice": "4000000000",
   "protocolFee": "0",
   "minimumProtocolFee": "0",
   "buyTokenAddress": "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d",
   "sellTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
   "buyAmount": "42418966555520202953",
   "sellAmount": "10000000000000000",
   "sources": [{
       "name": "Kyber",
       "proportion": "0"
   }, {
       "name": "0x",
       "proportion": "0"
   }, {
       "name": "SushiSwap",
       "proportion": "0"
   }, {
       "name": "Uniswap",
       "proportion": "0"
   }, {
       "name": "Uniswap_V2",
       "proportion": "0"
   }, {
       "name": "Uniswap_V3",
       "proportion": "1"
   }, {
       "name": "Curve",
       "proportion": "0"
   }, {
       "name": "Mooniswap",
       "proportion": "0"
   }],
   "orders": [{
       "makerToken": "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d",
       "takerToken": "0xc778417e063141139fce010982780140aa0cd5ab",
       "makerAmount": "42418966555520202953",
       "takerAmount": "10000000000000000",
       "fillData": {
           "router": "0xe592427a0aece92de3edee1f18e0157c05861564",
           "tokenAddressPath": ["0xc778417e063141139fce010982780140aa0cd5ab", "0xc715abcd34c8ed9ebbf95990e0c43401fbbc122d"],
           "uniswapPath": "0xc778417e063141139fce010982780140aa0cd5ab000bb8c715abcd34c8ed9ebbf95990e0c43401fbbc122d",
           "gasUsed": 64965
       },
       "source": "Uniswap_V3",
       "sourcePathId": "0xac8bbf4304525b617983fe7fd5a01469908809116bac0ef721423c1d662c4137",
       "type": 0
   }],
   "allowanceTarget": "0x0000000000000000000000000000000000000000",
   "sellTokenToEthRate": "1",
   "buyTokenToEthRate": "235.752005730940250098"
}

更新:氣體限制太低(直接從 0x api 獲取)。正如您在響應中看到的那樣,"gas": "149965",它應該更高(大約 300K wei)。即使沒有將 skipValidation 設置為 true,它仍然給出相同的結果。

https://ropsten.api.0x.org/swap/v1/quote?sellToken=ETH&buyToken=0xad6d458402f60fd3bd25163575031acdce07538d&sellAmount=100000000000000000&takerAddress=0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded

對比

https://ropsten.api.0x.org/swap/v1/quote?buyToken=0xad6d458402f60fd3bd25163575031acdce07538d&sellToken=ETH&sellAmount=100000000000000000&takeAddress=0xf5a64ea4fb8dff2b40450cd2016372c89e5e2ded

順序重要嗎?

更新:takerAddress 寫錯了(takeAddress)

takerAddress 寫錯了 (takeAddress)

引用自:https://ethereum.stackexchange.com/questions/124428