Enabling faucet plugin - need name/directory of script or node flag

Tutorial states to create script for enabling faucet but no filename or directory specified. Is this added to plugin.ts?
running the script with node in the root directory gives errors so my thought is that the script must run in a specific directory or requires a CLI flag.

const { apiClient } = require('@liskhq/lisk-client');
let clientCache;
const getClient = async () => {
  if (!clientCache) {
    clientCache = await apiClient.createWSClient('ws://localhost:8080/ws');
  }
  return clientCache;
};
const enableFaucet = async () => {
  const client = await getClient();
  const result = client.invoke('faucet:authorize',{"enable":true,"password":"password"});
  return result;
};
enableFaucet().then((val) => {
  console.log('val:',val);
});

Yes, this part of code is just to enable or disable plugin when it’s already loaded. It shouldn’t be put anywhere, it’s a standalone script. Your SDK app should be started with --enable-faucet-plugin parameter.

also don’t forget to put an encrypted passphrase to the plugin config. ex.

"plugins": {
		"faucet": {
	"encryptedPassphrase":"iterations=1000000&cipherText=ce...dcb4ac6324b92&salt=fa39bc44a8f68dd01177dbf,
	"captchaSecretkey": "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe",
    "captchaSitekey":"6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"
             }
}

I am running the blockchain and I am running the front end on localhost:3000. I opened up another shell, created a file called enable_faucet.js. Ran it on node js and get the error below. I tried connecting to localhost:4004 but that doesn’t connect. in the plugin it says the websocket is at localhost:8080 but that just throws an “upgrade required” page. why does the plugin code say connect to 8080 but the documentation says 4004 ?

hello_app$ sudo node enable_faucet.js --enable-faucet-plugin

(node:6056) UnhandledPromiseRejectionWarning: Error: Action ‘faucet:authorize’ is not registered to bus.
at Object.convertRPCError (/home/bob/Desktop/hello_app/node_modules/@liskhq/lisk-api-client/dist-node/utils.js:4:36)
at WSChannel._handleMessage (/home/bob/Desktop/hello_app/node_modules/@liskhq/lisk-api-client/dist-node/ws_channel.js:135:62)
at WebSocket.onMessage (/home/bob/Desktop/hello_app/node_modules/ws/lib/event-target.js:132:16)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/bob/Desktop/hello_app/node_modules/ws/lib/websocket.js:834:20)
at Receiver.emit (events.js:198:13)
at Receiver.dataMessage (/home/bob/Desktop/hello_app/node_modules/ws/lib/receiver.js:437:14)
at Receiver.getData (/home/bob/Desktop/hello_app/node_modules/ws/lib/receiver.js:367:17)
at Receiver.startLoop (/home/bob/Desktop/hello_app/node_modules/ws/lib/receiver.js:143:22)
at Receiver._write (/home/bob/Desktop/hello_app/node_modules/ws/lib/receiver.js:78:10)
(node:6056) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6056) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Hi @fovanessians First of all, you need to run your blockchain app with the --enable-faucet-plugin parameter (./bin/run start --enable-faucet-plugin --<other_parameters>), not the enable_faucet.js script. Yes the port 8080 is correct, that’s the port the plugin connects to the node. The port 4004 is the port where the frontend GUI of the faucet is, once you successfully launch it.

Hello, and thank you, I got that running, added the encrypted passphrase, under the plugins: faucet dictionary, ran the command with flags as you stated above. Faucet button is disabled (see photo below). I thought I was missing a plugin so I went to liskHQ in github to look for any missing plugins that would enable my public key account to receive test tokens, so i am stuck again:

The provided address has to be in the base32 format lskphdj2fkjp3upbtrmxuxjh4qevqen7en6tpkjjr