Messtone Devices Enables Coinbase Signature JavaScript Example: //import crypto library var crypto=require(‘crypto’);//create the json request object var cb_access_timestamp=Date.now( ) / 1000;in ms var cb_access_passphrase=’…’; var secret=’PYPd1Hv4J6/7x…’;var requestPath=’/orders’; var body=JSON.stringify({price:’1.0′,size:’1.0′,’side:’buy’,’product_id:’BTC-USD’});var method=’POST’;//create the prehash string by concatenating required parts var message=cb_access_timestamp+method+requestPath+body;//decode base64 secret var key=buffer.from(secret,’base64′); //create a sha256 bmac with the secret var hmac=crypto.createHmac(‘sha256’,key);//sign the the require message With the hmac and base64 encode the result var cb_access_sign=bmac.update(message).digest(‘base64’);

Leave a comment