Forum Academy Marketplace Showcase Pricing Features

Challenging Problem - Sequence of Actions in Workflow - Binance API

Hey everyone,

Need some help please. I’m kinda stuck.

I’m trying to execute the following series of actions in an orderly fashion.

When current user clicks the ‘SELL’ button, the following occurs. All these actions need to happen at the click of the ‘SELL’ button.

  1. A fresh timestamp gets generated using the following command:
    TimeStamp = Current date/time:extract UNIX

  2. Concatenate the following two strings together (note String 2 is the TimeStamp from step 1):
    String 1 = ‘symbol=VETUSDT&side=SELL&type=MARKET&quantity=1&recvWindow=60000000&timestamp=’
    String 2 = TimeStamp
    String 3 = String 1 + String 2

  3. Generate a SHA-256 encryption of the following two items:
    Item 1 = ‘symbol=VETUSDT&side=SELL&type=MARKET&quantity=1&recvWindow=60000000&timestamp=TimeStamp’ (or String 3 from above)
    Item 2 = ‘NhqPtmdSJYdKjVHjA7PZj4Mge3R5YNiP1e3UZjInClVN65XAbvqqM6A7H5fATj0j’ (This is the Static Secret Key)
    Output = SHA-256 Encryption of (Item 1, Item 2)
    *** For this, I use a plugin called ‘Base64, Hash & HMAC Encryptor’

  4. Perform an API Call (*** For this, I use the API Connector) and pass in the TimeStamp and Output from Step 3:

That’s it!

The problem is that all these actions run at the same time ‘apparently’ and I need them to run one after the other in an orderly fashion.

API Documentation for Binance:
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md

Really appreciate any help on this. Thanks!

dax3k

Someone smarter than I may weigh in, but can you create multiple custom events (or api endpoints, if you prefer doing this all in the api), each with 1 of your steps, where once each one is finished, it calls the next event? That way, you’ll be sure each step is done before the next one.

By doing this on a page workflow and using a client-side script for the hash signature, you are exposing your app’s secret key to the end user.

You should be doing this step on the server side, i.e. in an API workflow. Bubble has a text function for HMAC SHA256 which you can use.

1 Like

Thank you mishav, this is very helpful.

May I ask how you would go by implementing the above four steps in an API workflow please?

Do I have to create an ‘Endpoint’ that is triggered when the ‘SELL’ button is clicked?

How do I configure the actions inside the endpoint to align with the sequence of actions in my original post?

Thank you so much for any help!
dax3k

Hi @dax3k

Yes this is how an API workflow starts.

You can start it in one of two ways :

  • Schedule API Workflow. This runs it in the background, giving control of the page back to the user without waiting for it to finish. The page would rely on some database update to know any results.

  • API Connector to your own app endpoint. This runs the workflow, and shows Bubble’s progress bar while it runs, then optionally accepts a result from the workflow when it has one.

1 Like

Did you solve the problem?