简体   繁体   English

使用coinbase API购买ETH

[英]Buying ETH using coinbase API

According to documentation, I should be able to buy ETH using coinbase API (see Place buy order ). 根据文档,我应该能够使用coinbase API购买ETH(参见购买订单 )。

Now, looks like I am getting BTC instead. 现在,看起来我正在获得BTC。

private static void placeNonCommitBuy(String paymentMethod) {
    if (sAccountID != null) {
        String url = String.format("https://api.coinbase.com/v2/accounts/%s/buys", sAccountID);

        try {
            JSONObject params = new JSONObject();
            params.put("amount", "0.001");
            params.put("currency", "ETH");
            params.put("payment_method", paymentMethod);
            params.put("agree_btc_amount_varies", true);
            params.put("commit", false);
            params.put("quote", true);

            doPost(url, params, sJustPrint);
        } catch (JSONException ex) {
            Assert.fail();
        }
    }
}

I got that confirmation : 我得到了确认:

{
  "data": {
    "id": <...snip...>,
    "status": "created",
    "payment_method": {
      "id": <...snip...>,
      "resource": "payment_method",
      "resource_path": <...snip...>
    },
    "transaction": null,
    "user_reference": <...snip...>,
    "created_at": "2018-01-18T01:37:15Z",
    "updated_at": "2018-01-18T01:37:16Z",
    "resource": "buy",
    "resource_path": <...snip...>,
    "fee": {
      "amount": "0.99",
      "currency": "USD"
    },
    "amount": {
      "amount": "0.00008968",
      "currency": "BTC"
    },
    "total": {
      "amount": "2.02",
      "currency": "USD"
    },
    "subtotal": {
      "amount": "1.03",
      "currency": "USD"
    },
    "committed": true,
    "payout_at": "2018-01-18T01:37:14Z",
    "instant": true,
    "requires_completion_step": false
  }
}

In the website, I see that I now have some BTC (about 1 USD worth of it), but not ETH. 在网站上,我看到我现在有一些BTC(价值约1美元),但不是ETH。

Is there a missing / undocumented params I need to use? 我需要使用缺失/无证的params吗? Or a mistake in my request? 或者我的请求中有错误?

So, looks like the Coinbase API isn't actually taking the currency field into consideration (even if their API documentation mention that and explain what it does). 因此,看起来Coinbase API实际上没有考虑currency字段(即使他们的API文档提到并解释它的作用)。

What happen is that your transaction will take place using whatever currency is associated with the account that was authorized by the user as part of the Oauth process. 发生的事情是,您的交易将使用与用户授权的帐户关联的任何货币作为Oauth流程的一部分进行。 By default it select BTC; 默认选择BTC; the user has to click that dropdown and pick something else. 用户必须单击该下拉列表并选择其他内容。

So the "fix" is to make sure the user select the proper account. 所以“修复”是为了确保用户选择正确的帐户。

The real fix is that Coinbase fix their API and return an error if the currency you select isn't authorized (instead of ignoring that field and using the authorized currency without telling anyone). 真正的解决方案是,如果您选择的货币未经授权,Coinbase会修复其API并返回错误(而不是忽略该字段并使用授权货币而不告诉任何人)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 eth.coinbase的eth.sendTransaction进行多次交易并减少eth.coinbase余额 - eth.sendTransaction from eth.coinbase makes multiple transactions and decrease the eth.coinbase balance 有没有办法使用 Coinbase API 获取以太坊价格数据? - Is there a way to get Ethereum price data using the Coinbase API? 使用 Coinbase 从一种加密货币转换为另一种加密货币 API - Convert from one crypto to another using Coinbase API 历史以太坊价格 - Coinbase API - Historical ethereum prices - Coinbase API 如何使用 UniswapV2 将 ETH 与 WETH 交换? - How to swap ETH with WETH using UniswapV2? 有关CORS政策问题,请访问https://api.myetherwallet.com/eth - CORS policy issue at https://api.myetherwallet.com/eth 如何发送wei/eth到合约地址? (使用松露 javascript 测试) - How to send wei/eth to contract address? (using truffle javascript test) 在scaffold-eth上实施Uniswap v3 API单交换示例-错误:无法估计气体 - Implementing Uniswap v3 API single swap example on scaffold-eth - ERROR: cannot estimate gas 从 Opensea API 中的 opensea current_price 计算显示的 eth 价格 - Calculate displayed eth price from opensea current_price in Opensea API METAMASK - 注入 - 用户如何使用 metamask API 支付自定义价值的 ETH? - METAMASK - injection - How user can pay custom value of ETH with metamask API?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM