0

Anyone have thoughts on Crypto.com API for create order.

I am having no luck. I can only get unauthorized. I cannot seem to find good code sample of what the final hmac string should be.

<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 STRING FOR ENCRYPT

private/create-order121qerX99999w75583kiSMqjpinstrumentnameXLMUSDTquantity1000sideselltypemarket1654206264743

  <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> 

If anyone knows a JAVASCRIPT version - I could push that as well. But wow. This exchange API is not fun.

Merle_the_Pearl
  • 1,391
  • 3
  • 18
  • 25
  • have you tried with python? – Alex B Jun 09 '22 at 23:37
  • No I use ColdFusion on Windows Server. I actually got sorted. Might have been as simple as SELL vs sell. Also. Next problem is if selling 2323.45.. The encryption doens't like the decimal. Which is fine I can strip. But on the Param push it is 2323.45 encryption 232345. Doesn't work. But 2323 works no probs. Its some more trial and error. I updated the other post from awhile ago. Thx for note. – Merle_the_Pearl Jun 11 '22 at 00:07

0 Answers0