Signed endpoint and HMAC SHA256 in React


I wanna fetch data, and also make a trade using signed endpoints, which requires an additional parameter, HMAC SHA256 signature, to be sent in the queryString or requestBody.

Binance API - Endpoint Security Type info

API-keys are passed into the Rest API via the X-MBX-APIKEY header.

I’m using “crypto-js” (for HMAC SHA256 signature) and “” to send queryString.

I came up with some code for placing an order, but it seems that something is not configured quite right.

I uploaded files to GitHub, so if there’s anyone who could help, can check the PAGE and the CODE.

Just one thing to mention, change API and secret key with your own to test it out.

Thank you!



1 Like

The solution/answer to hashing the signature:

const crypto = require('crypto');

const query_string = 'timestamp=1578963600000';
const apiSecret = 'NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j';

function signature(query_string) {
    return crypto
        .createHmac('sha256', apiSecret)

console.log("hashing the string: ");
console.log("and return:");


const another_query = 'symbol=LTCBTC&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=0.1&recvWindow=5000&timestamp=1499827319559';
console.log("hashing the string: ");
console.log("and return:");

but there is a new problem arrived

locked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response

…and that’s for a “New Topic”