Steem Developer Portal

This tutorial runs on the main Steem blockchain. And accounts queried/searched are real accounts with their available VESTS balances and estimated STEEM POWER holdings.

Intro

This tutorial will show few functions such as querying account by name and getting account vesting balance. We then convert VESTS to STEEM POWER for convenience of user. And allow user to choose portion or all holdings of VESTS to delegate other users. A simple HTML interface is provided to capture the account with search and its VESTS balance as well as allowing interactively delegate. It should be noted that when a delegation is cancelled, the VESTS will only be available again after a 5 day cool-down period.

Delegate power Delegate VESTS with Steemconnect or Client-side signing.

1. App setup

Below we have dsteem pointing to the production network with the proper chainId, addressPrefix, and endpoint. There is a public/app.js file which holds the Javascript segment of this tutorial. In the first few lines we define the configured library and packages:

constdsteem=require('dsteem');letopts={};//connect to production serveropts.addressPrefix='STM';opts.chainId='0000000000000000000000000000000000000000000000000000000000000000';//connect to server which is connected to the network/productionconstclient=newdsteem.Client('https://api.steemit.com');

2. Search account

After account name field is filled with some name, we do automatic search for account by name when input is focused out. HTML input forms can be found in the index.html file. The values are pulled from that screen with the below:

3. Calculate and Fill form

After we fetched account data, we will fill form with VESTS balance and show current balance details. Note, that in order to get available VESTS balance we will have to check if account is already powering down and how much is powering down, how much of VESTS were delegated out which locks them from being powered down. Available balance will be in avail variable, next for convenience of user, we convert available VESTS to STEEM with getDynamicGlobalProperties function and fill form fields accordingly.

Once form is filled with maximum available VESTS balance, you can choose portion or lesser amount of VESTS to delegate other user.

4. Delegate power

We have 2 options on how to delegate others. Steemconnect and Client-side signing options. By default we generate Steemconnect link to delegate power (delegate vesting shares), but you can choose client signing option to delegate right inside tutorial, note client-side signing will require Active Private key to perform the operation.

In order to enable client signing, we will generate operation and also show Active Private key (wif) field to sign transaction client side.
Below you can see example of operation and signing transaction, after successful operation broadcast result will be shown in user interface. It will be block number that transaction was included.