AuroraDAO / idex-api-docs

IDEX API documentation (work in progress)
81 stars 27 forks source link

Example of Trade method #14

Closed freezepro closed 6 years ago

freezepro commented 6 years ago

Thanks for the api docs, could you please provide example on how to get nonce and v,r,s values. Thanks!

const salted = hashPersonalMessage(toBuffer(raw)) const { v, r, s } = mapValues(ecsign(salted, privateKeyBuffer), (value, key) => key === 'v' ? value : bufferToHex(value)); // send v, r, s values in payload

freezepro commented 6 years ago

I found and tried this one previously at etherdelta, and I understand it's quite close to what you suggest to do here, but quick new to ETH library stuff...however approach below is quick complex and I found some error in there(while executing order).

https://github.com/etherdelta/bots/blob/master/js/service.js lines 447 - 520

RZeynalov commented 6 years ago

Freezepro, have you managed to solve this problem and process trades? if yes, d you be so kind and share your solution. Thank you in advance!

cheenid commented 6 years ago

Hi guys, who can tell me how to get 'privateKeyBuffer', thanks a lot.

snowzhaoo commented 6 years ago

@cheenid new Buffer('privateKeyBuffer', 'hex')

cheenid commented 6 years ago

@vicsnow Thanks mate😊

fubar commented 6 years ago

@freezepro Did you get this sorted out? The procedure to generate a signature should be sufficiently explained in the docs under Contract-backed trade functions (https://github.com/AuroraDAO/idex-api-docs#contract-backed-trade-functions). There's a code sample under the "order" section.

Closing this issue; let me know if you need further assistance.