---
title: "BitMart Faster Hmac Sign JavaScript SDK Example | Siebly"
description: "BitMart Auth faster hmac sign JavaScript example for the Siebly BitMart SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs."
canonical: "https://siebly.io/examples/Bitmart/Auth/fasterHmacSign"
robots: "index,follow"
---

# BitMart Faster Hmac Sign JavaScript SDK Example

BitMart Auth faster hmac sign JavaScript example for the Siebly BitMart SDK, covering exchange REST API and WebSocket integration, setup, and production SDK docs.

**Path:** [Home](/) / [Examples](/examples) / [Bitmart](/examples/Bitmart) / [Auth](/examples/Bitmart/Auth) / [fasterHmacSign.ts](/examples/Bitmart/Auth/fasterHmacSign)

[View source on GitHub](https://github.com/sieblyio/crypto-api-examples/blob/master/examples/Bitmart/Auth/fasterHmacSign.ts)

[Open the BitMart JavaScript SDK guide](/sdk/bitmart/javascript)

## fasterHmacSign.ts

```typescript
import { RestClient } from 'bitmart-api';
import { createHmac } from 'crypto';

const account = {
  key: process.env.API_KEY || 'apiKeyHere',
  secret: process.env.API_SECRET || 'apiSecretHere',
  memo: process.env.API_MEMO || 'apiMemoHere',
};

const client = new RestClient({
  apiKey: account.key,
  apiSecret: account.secret,
  apiMemo: account.memo,
  /**
   * Overkill in almost every case, but if you need any optimisation available,
   * you can inject a faster sign mechanism such as node's native createHmac:
   */
  customSignMessageFn: async (message, secret) => {
    return createHmac('sha256', secret).update(message).digest('hex');
  },
});

async function getSpotBalances() {
  try {
    const balances = await client.getAccountBalancesV1();

    console.log('Balances: ', JSON.stringify(balances, null, 2));
  } catch (e) {
    console.error('Req error: ', e);
  }
}

getSpotBalances();
```
