Steem Blockchain Local Broadcast JavaScript Tool

in Steem Dev ā€¢ 3 days ago (edited)

image.png

Hi therešŸ‘‹
It's been a while since I have posted on Steemit, I was away from posting and updating witness activities because the MSS Exam is going on at my University, almost at the end of my University academic lifešŸ˜…

This project is designed to make it easier for developers and Steem users to interact with the Steem blockchain using JavaScript while locally hosting, the scripts and tools run on your local machine, allowing you to interact with the Steem blockchain directly from your computer. For now, I have created only two features for delegating STEEM Power and returning delegations, I will add more features in future. If you are worried about your private keys being exposed this is really for you!


What Does This Project Do?

The project provides a set of JavaScript scripts that allow you to:

  1. Delegate STEEM Power (VESTS): Easily delegate STEEM Power to other accounts.
  2. Return Delegated STEEM Power: Return delegated STEEM Power from other accounts.
  3. User-Friendly Input: Specify amounts in STEEM instead of VESTS for convenience.

How to Get Started

Prerequisites

Before running the scripts, make sure you have the following installed:

  • Node.js
  • npm
  • VS Code (or any code editor of your choice)

Installation

  1. Clone the repository:

    git clone https://github.com/Steemblocks/Steem-Local-Broadcast.git  
    cd Steem-Local-Broadcast  
    
  2. Install the required dependencies:

    npm install  
    
  3. Edit the config.js file and add your Steem account details:

    username: 'your-userid', // Replace with your Steem username  
    activeKey: 'your-active-key', // Replace with your active private key  
    

How to Use the Scripts

Delegate STEEM Power

To delegate STEEM Power to another account, use the steemDelegate.js script:

node steemDelegate.js <delegatee> <steemAmount>  
  • <delegatee>: The account you want to delegate to.
  • <steemAmount>: The amount of STEEM to delegate.

Example:

node steemDelegate.js "the-gorilla" 100

This delegates 100 STEEM worth of VESTS to the account the-gorilla.

Output example: You will get a response like this

PS C:\Users\hp\Downloads\Steem Local Broadcast> node steemDelegate.js "the-gorilla" 100
Delegation Transaction: {
  id: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  block_num: 94060xxxx,
  trx_num: x,
  expired: false,
  ref_block_num: 15xxx,
  ref_block_prefix: 2618191xxxxx,
  expiration: '2025-03-23T06:43:24',
  operations: [ [ 'delegate_vesting_shares', [Object] ] ],
  extensions: [],
  signatures: [
    '1f54d4ddc83c1d5df878bf70eefa840fde6168b5550a598429306f5a2597264fff22db70xxxxxxxxxxxxxxxxxxxx'
  ]
}

Return Delegated STEEM Power

To return delegated STEEM Power from another account, use the cancelDelegation.js script:

node cancelDelegation.js <delegatee> <steemAmount>  
  • <delegatee>: The account you want to return delegation from.
  • <steemAmount>: The amount of STEEM to return.

Example:

node cancelDelegation.js "avro33" 0.00  

This returns all the STEEM delegation from the account avro33. You can then delegate again using the steemDelegate.js script.

Output example: You will get a response like this

PS C:\Users\hp\Downloads\Steem Local Broadcast> node cancelDelegation.js "avro33" 0   
Return Vesting Delegation Transaction: {
  id: 'ea6ad233fbe23213045dxxxxxxxxxxxxxxxx',
  block_num: 940xxxx,
  trx_num: 1,
  expired: false,
  ref_block_num: 160xx,
  ref_block_prefix: 1227xxxxxx,
  expiration: '2025-03-23T06:46:03',
  operations: [ [ 'delegate_vesting_shares', [Object] ] ],
  extensions: [],
  signatures: [
    '2066badbba0968066b7532349f656fb6e3a2cbf2353641d1e16402554d822xxxxxxxxxxxxxxxxxxxxxxx'
  ]
}

image.png

A Note on Security

While installing npm you will get security alerts and discover some high severity vulnerabilities, these are caused by the outdated dependencies in our Steem-js.

PS C:\Users\hp\Downloads\Steem Local Broadcast> npm audit report 
# npm audit report

cross-fetch  <=2.2.5 || 3.0.0 - 3.1.4 || 3.2.0-alpha.0 - 3.2.0-alpha.2
Severity: high
Incorrect Authorization in cross-fetch - https://github.com/advisories/GHSA-7gc6-qh9x-w6h8
Depends on vulnerable versions of node-fetch
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/cross-fetch
  steem  >=0.6.0-beta.0
  Depends on vulnerable versions of cross-fetch
  Depends on vulnerable versions of ws
  node_modules/steem

node-fetch  <2.6.7
Severity: high
node-fetch forwards secure headers to untrusted sites - https://github.com/advisories/GHSA-r683-j2x4-v87g
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/node-fetch

ws  2.1.0 - 5.2.3
Severity: high
ws affected by a DoS when handling a request with many HTTP headers - https://github.com/advisories/GHSA-3h5v-q93c-6h6q
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/ws

4 high severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

These issues are being addressed urgently, and I have informed our core developers, hoping they will update the JavaScript libraries soon.

During installation, if you run npm audit fix --force It breaks the script and doesn't work. If you keep it as it is, then it works fine. But we need the Steem-js update asap.


Contribute and Collaborate

This project is open-source, and Iā€™d love for the community to get involved! If you have any suggestions, find bugs, or want to contribute, feel free to open an issue or submit a pull request on the GitHub repository.


Special Thanks

I would love to express my gratitude towards our seniors @steemchiller and @the-gorilla, for being always friendly, quick to help, and endlessly supportive. Weā€™re so proud to have you, and your dedication inspires us every day. Thank you for being amazing!

Final Thoughts

I hope this project makes it easier for developers and Steem users to interact with the blockchain. Whether youā€™re delegating STEEM Power or managing your delegations, these tools are designed to simplify the process.

Letā€™s keep building and growing the Steem ecosystem together! šŸ’Ŗ


Check out the project here:
GitHub Repository

Feel free to leave your feedback or questions in the comments below. Letā€™s make Steem even better! šŸš€

Cheers,
@shahriar33
Dhaka Witness