Javascript/NodeJS Function to Check the Plugins on Steem Blockchain RPC Nodes by justyy

View this thread on steempeak.com
· @justyy ·
$59.43
Javascript/NodeJS Function to Check the Plugins on Steem Blockchain RPC Nodes
Previously: [API Added - Check Plugins of RPC Node](https://steemit.com/witness-category/@justyy/api-added-check-plugins-of-rpc-node)

The <a href="https://helloacm.com/compute-the-account-voting-power-mana-for-accounts-on-steem-blockchain-using-javascript-nodejs-function/" title="Compute the Account Voting Power (Mana) for Accounts on Steem Blockchain using Javascript/NodeJs Function">Steem Blockchain</a> RPC nodes have a few plugins that can be configured enabled/disabled. We can use the following Javascript function (NodeJS) to check if those plugins are enabled or disabled.

To check if a plugin is enabled or not, we need to sent the API (POST) with the corresponding parameters to invoke some API of that plugin. If it returns errors containing the "cannot find method", the plugin is disabled.

See below JS function callAPI which takes the RPC Node Server, the Plugin Name, the API Method, and its parameters. It returns true if the plugin has been enabled - otherwise meaning the plugin has been deactivated.

```
async function callAPI(server, plugin, api, params) {
  try {
    const body = JSON.stringify({"id":1,"jsonrpc":"2.0","method":plugin+"."+api,"params":params});
    const response = await fetch(server, {
      method: "POST",
      headers: {
        'Content-Type': 'application/json'
      },
      body: body
    });
    if (response.ok) {
      const data = await response.text();      
      const jsonData = JSON.parse(data);  
      const magicString = "Assert Exception:api_itr != _registered_apis.end()";
      const succ = (!jsonData["error"]) || (!jsonData["error"]["message"].includes(magicString));
      return succ;
    } else {
      return false;
    }
  } catch (ex) {
    return false;
  }
}
```

The list of plugins, and their one example API, with parameters can be defined as:

```
  const plugins = {
    "account_by_key_api": ["get_key_references", {"keys":["STM5jZtLoV8YbxCxr4imnbWn61zMB24wwonpnVhfXRmv7j6fk3dTH"]}],
    "account_history_api": ["get_account_history", {"account":"steemit", "start":1000, "limit":1000}],
    "block_api": ["get_block",{"block_num":1}],
    "database_api": ["list_account_recovery_requests",{"start":"", "limit":10, "order":"by_account"}],	
    "condenser_api": ["get_accounts", [["justyy"]]],
    "debug_node_api": ["debug_pop_block"],
    "follow_api": ["get_account_reputations",{"account_lower_bound":"steemit", "limit":1}],
    "market_history_api": ["get_ticker"],
    "rc_api": ["find_rc_accounts",{"accounts":["alice","bob"]}],
    "reputation_api": ["get_account_reputations",{"account_lower_bound": "steem"}],
    "rewards_api": ["simulate_curve_payouts",{"curve": "quadratic", "var1": "2000000000000"}],
    "tags_api": ["get_discussion",{"author":"alice", "permlink":"a-post-by-alice"}],
    "transaction_status_api": ["find_transaction",{"transaction_id": "0000000000000000000000000000000000000000", "expiration":"2016-03-24T18:00:21"}],
    "network_broadcast_api": ["broadcast_block",{"trx":{"ref_block_num":1097,"ref_block_prefix":2181793527,"expiration":"2016-03-24T18:00:21","operations":[{"type":"vote_operation","value":{"voter":"steemit","author":"alice","permlink":"a-post-by-alice","weight":10000}}],"extensions":[],"signatures":[]},"max_block_age":50}],
  };
```

And we can test each plugin one by one:

```
  let result = {
    "node": node,
    "enabled_plugins": [],
    "disabled_plugins": [],
  };
  const pluginNames = Object.keys(plugins);
  for (let i = 0; i &lt; pluginNames.length; ++ i) {
    const plugin = pluginNames[i];
    const api = plugins[plugin];
    const params = api.slice(1)[0];
    const succ = await callAPI(node, plugin, api[0], params);
    if (succ) {
      result["enabled_plugins"].push(plugin);
    } else {
      result["disabled_plugins"].push(plugin);
    }
  }
```

See also: <a href="https://helloacm.com/how-to-get-blockchain-version-of-steem-rpc-node-using-javascript/" title="How to Get Blockchain Version of Steem RPC Node using Javascript?">How to Get Blockchain Version of Steem RPC Node using Javascript?</a>

Reposted to [Blog](https://helloacm.com/javascript-nodejs-function-to-check-the-plugins-on-steem-blockchain-rpc-nodes/)

@steemcurator01
@steemcurator02
@steemcurator03
@steemcurator04
@steemcurator05
@steemcurator06
@steemcurator07
@steemcurator08
@steemcurator09

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^
---------------
## NEW! [Following my Trail (Upvote or/and Downvote)](https://steemit.com/witness-category/@justyy/following-my-trail-upvote-or-and-downvote-by-authorizing-posting-key-to-me)




Follow me for topics of *Algorithms, Blockchain and Cloud.*
I am @justyy - a Steem Witness
[https://steemyy.com](https://steemyy.com)

#### My contributions
- [Steem Blockchain Tools](https://steemyy.com)
- *[Computing &amp; Technology](https://helloacm.com/)*
- *[Download Youtube Video](https://weibomiaopai.com/download-video-parser.php)*
- Find Cheap &amp; Bargin VPS: *[VPS Database](https://anothervps.com/vps-database/)*
- [Online Software and Tools](https://steakovercooked.com/Software.Home)
- [Online File/Video Merger](https://slowapi.com/merge-videos/)

#### Delegation Service
1. [Voting Algorithm Updated to Favor those High Delegations!](https://steemit.com/wherein/@justyy/voting-algorithm-updated-to-favor-those-high-delegations)

- Delegate 1000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amp;amount=1000)
- Delegate 5000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amp;amount=5000)
- Delegate 10000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amp;amount=10000)

#### Support me
If you like my work, please: 
- [Buy Me a Coffee](https://justyy.com/out/buymeacoffee), Thanks!
- [Become my Sponsor](https://github.com/sponsors/DoctorLai), Thanks!
- Voting for me:
https://steemit.com/~witnesses type in **justyy** and click ***VOTE***
https://steemyy.com/images/vote-for-justyy.jpg


1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
2. Vote @justyy as Witness:  https://steemyy.com/witness-voting/?witness=justyy&amp;action=approve
3. Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&amp;action=proxy
Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses


-------------
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 77 others
properties (23)
post_id91,063,275
authorjustyy
permlinkjavascript-nodejs-function-to-check-the-plugins-on-steem-blockchain-rpc-nodes
categorywitness-category
json_metadata{"tags":["witness-category","whalepower","witness","sct","programming","steemit","steemdev","steemtools"],"users":["steemcurator01","steemcurator02","steemcurator03","steemcurator04","steemcurator05","steemcurator06","steemcurator07","steemcurator08","steemcurator09","justyy"],"image":["https:\/\/steemyy.com\/images\/vote-for-justyy.jpg"],"links":["https:\/\/steemit.com\/witness-category\/@justyy\/api-added-check-plugins-of-rpc-node","https:\/\/helloacm.com\/compute-the-account-voting-power-mana-for-accounts-on-steem-blockchain-using-javascript-nodejs-function\/","https:\/\/helloacm.com\/how-to-get-blockchain-version-of-steem-rpc-node-using-javascript\/","https:\/\/helloacm.com\/javascript-nodejs-function-to-check-the-plugins-on-steem-blockchain-rpc-nodes\/","https:\/\/steemit.com\/witness-category\/@justyy\/following-my-trail-upvote-or-and-downvote-by-authorizing-posting-key-to-me","https:\/\/steemyy.com","https:\/\/helloacm.com\/","https:\/\/weibomiaopai.com\/download-video-parser.php","https:\/\/anothervps.com\/vps-database\/","https:\/\/steakovercooked.com\/Software.Home","https:\/\/slowapi.com\/merge-videos\/","https:\/\/steemit.com\/wherein\/@justyy\/voting-algorithm-updated-to-favor-those-high-delegations","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amp;amount=1000","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amp;amount=5000","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amp;amount=10000","https:\/\/justyy.com\/out\/buymeacoffee","https:\/\/github.com\/sponsors\/DoctorLai","https:\/\/steemit.com\/~witnesses","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy","https:\/\/steemyy.com\/witness-voting\/?witness=justyy&amp;action=approve","https:\/\/steemyy.com\/witness-voting\/?witness=justyy&amp;action=proxy"],"app":"steemit\/0.2","format":"markdown"}
created2021-05-10 15:07:45
last_update2021-05-10 15:07:45
depth0
children2
net_rshares35,567,992,322,430
last_payout2021-05-17 15:07:45
cashout_time1969-12-31 23:59:59
total_payout_value29.772 SBD
curator_payout_value29.656 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length6,365
author_reputation2,057,469,156,047,835
root_title"Javascript/NodeJS Function to Check the Plugins on Steem Blockchain RPC Nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (141)
@chaofanjun ·
$0.30
我以为行长没发今天的编程教程,结果翻了一下19小时前发过了,哈哈!

[WhereIn Android] (http://www.wherein.io)
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 16 others
properties (23)
post_id91,064,266
authorchaofanjun
permlinkwherein-1620661814210
categorywitness-category
json_metadata{}
created2021-05-10 15:50:18
last_update2021-05-10 15:50:18
depth1
children1
net_rshares316,493,158,046
last_payout2021-05-17 15:50:18
cashout_time1969-12-31 23:59:59
total_payout_value0.150 SBD
curator_payout_value0.148 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length76
author_reputation3,260,868,859,118
root_title"Javascript/NodeJS Function to Check the Plugins on Steem Blockchain RPC Nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (80)
@justyy ·
哇哈哈
properties (22)
post_id91,064,849
authorjustyy
permlinkqswfzi
categorywitness-category
json_metadata{"app":"steemit\/0.2"}
created2021-05-10 16:18:57
last_update2021-05-10 16:18:57
depth2
children0
net_rshares0
last_payout2021-05-17 16:18:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length3
author_reputation2,057,469,156,047,835
root_title"Javascript/NodeJS Function to Check the Plugins on Steem Blockchain RPC Nodes"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000