【问题标题】:Crypto.com API - Create OrderCrypto.com API - 创建订单
【发布时间】:2022-06-11 08:09:33
【问题描述】:

任何人都对 Crypto.com API 创建订单有想法。

我运气不好。我只能获得未经授权的。 我似乎找不到最终的 hmac 字符串应该是什么的好的代码示例。

<cfset pl = "instrumentnameXLMUSDTquantity1000sideselltypemarket">

<cfset strp = '{"instrument_name":"XLM_USDT","quantity":1000,"side":"sell","type":"market"}'>

 <cfscript>

apiKey = "#cr_key#";
apiSecret = "#cr_s#";

hmacm = #req_path# & 121 & apikey & #pl# & #unixdatetimeNow.getTime()#;

CrHex = hmac(hmacm, apiSecret, "HmacSHA256");

theKeyBytes = charsetDecode(ApiSecret, "UTF-8");
crsign = lcase(hmac(hmacm, apiSecret, "HmacSHA256"));

newbody = serializeJSON({
"api_key": "#cr_key#",
"method": "#req_path#",
"id": 121,
"params": deserializeJSON(#strp#),
"nonce": #unixdatetimeNow.getTime()#, 
"sig": "#crsign#"
});

 </cfscript> 

用于加密的 HMACM 字符串

私人/创建订单121qerX99999w75583kiSMqjpinstrumentnameXLMUSDTquantity1000sideselltypemarket1654206264743

  <CFHTTP METHOD="POST" URL="#base_api##req_path#" result="result">
  <cfhttpparam type="header" name="Content-Type" value="application/json">
  <cfhttpparam type="body" value="#newbody#">
  </cfhttp> 

如果有人知道 JAVASCRIPT 版本 - 我也可以推送。但是哇。这个交换 API 不好玩。

【问题讨论】:

  • 你用 python 试过了吗?
  • 不,我在 Windows Server 上使用 ColdFusion。我真的被整理了。可能就像卖出与卖出一样简单。还。下一个问题是如果出售 2323.45.. 加密不喜欢小数。这很好,我可以剥离。但是在 Param push 上它是 2323.45 加密 232345。不起作用。但是 2323 没有问题。它的一些更多的试验和错误。我更新了不久前的另一篇文章。谢谢提醒。

标签: api coldfusion-2016 crypto.com-exchange-api


【解决方案1】:

终于破解了。向后工作到帐户摘要工作。 SELL 和 MARKET 可能是大写字母。

我只是使用简单的 cfsets 来按字母顺序排列字符串。

<cfset unixdatetimeNow = dateConvert( "local2Utc", now() )>

<cfset pl = "instrument_nameXLM_USDTquantity5000sideSELLtypeMARKET">

<cfset strp = '{"instrument_name": "XLM_USDT","quantity": 5000,"side": "SELL","type": "MARKET"}'>

<cfscript>
  apiKey = "#cr_key#";
  apiSecret = "#cr_s#";

  hmacm = #req_path# & 121 & apikey & #pl# & #unixdatetimeNow.getTime()#;

  CrHex = hmac(hmacm, apiSecret, "HmacSHA256");

  theKeyBytes = charsetDecode(ApiSecret, "UTF-8");
  crsign = lcase(hmac(hmacm, apiSecret, "HmacSHA256"));

</cfscript>

<cfset fullbody = '{"api_key": "#cr_key#","id": 121,"method": "#req_path#","params": #strp#,"sig": "#crsign#","nonce": #unixdatetimeNow.getTime()#}'>

<CFHTTP METHOD="POST" URL="#base_api##req_path#" result="result">
<cfhttpparam type="header" name="Content-Type" value="application/json">
<cfhttpparam type="body" value="#fullbody#">
</cfhttp> 

【讨论】:

    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-12
    • 2021-11-03
    相关资源
    最近更新 更多