I want to increase nonce for each HTTP request.

Asked 2 years ago, Updated 2 years ago, 97 views

I use coincheck API and gem to create an app.
When I tried to execute two requests without pause,

{"success"=>false, "error"=>"Nonce must be incremented"}

The error returned.
Documentation includes

 A positive integer that must increase per ACCESS-NONCE request.Typically, UNIX timestamps are used.The maximum value is 9223372036854775807.Managed for each API key.

https://coincheck.com/ja/documents/exchange/api#auth

It says, but how can I increase nonce for each request?
I use this gem.
https://github.com/coincheckjp/ruby_coincheck_client

The code for the affected parts is as follows:

[email protected]_orders (market_buy_amount: 10000, order_type: "market_buy")
  result=JSON.parse(response.body)

  # If the response is success=true, start sending.
  result ['success']
  if result ['success'] == true then
     # Remittance processing, error
     [email protected]_send_money(address: "xxxx", amount: "0.1")
  end

ruby api http

2022-09-30 19:44

2 Answers

Currently, the affected gem seems to have solved the problem with the pull-request below.
https://github.com/coincheckjp/ruby_coincheck_client/pull/7


2022-09-30 19:44

"It says ""Run without pause"", but does it mean that one second has not passed?" If that's the case, I think the specification of using UNIX timestamps implicitly prohibits access for less than one second...

As a technical solution, I don't think it's a problem if you use milliseconds or microseconds instead of seconds.

-Time.now.to_i.to_s
+Time.now.to_i.to_s +format('%06d', Time.now.usec)


2022-09-30 19:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.