How to get output of contract function of hello {'user'} to webpage using eosjs?
I had deploy the smart contract to print the hello {'username'} in terminal and now i want to use this contract to interact with the webpage using the eosjs. so I want to take an input from the user in textbox "username" and then call my contract and print the Hello "user_entered_name". Any help !!!!
my index.js File code
Eos = require("eosjs");
const fs = require("fs");
// Optional configuration..
config = {
keyProvider: ["5KSPPksyPuRg2LVRCh4jAKfD4VPBoNbUCMpvvFXnStWbb5WpYhb"], // WIF string or array of keys..
httpEndpoint: "http://127.0.0.1:8888"
};
config.binaryen = require("binaryen");
eos = Eos(config);
wast = fs.readFileSync('/home/yudiz/eos/contracts/tutorial/hello/hello.wast');
abi = fs.readFileSync('/home/yudiz/eos/contracts/tutorial/hello/hello.abi');
// Publish contract to the blockchain
eos.setcode("faucet", 0, 0, wast, abi);
eos.contract("faucet").then(hello => {
hello.hi('axay', { authorization: ["faucet"] }).then(res => { //currently taking username static 'axay'
console.log(res);
});
});
the transaction occur in terminal when i run node index.js but in website how can i acess it and print the message?
Currently db plugin is underdevelopment for EOS v1.0.1, so you can use history_plugin with --filter-on.
so, it will help you to get transaction info and there you can see the output of your function call.
use this command to start nodeos:
./nodeos --plugin eosio::history_api_plugin --filter-on "*"
A db plugin mirrors content (transactions, etc.) to a db. Your app then interacts with the db. The history plugin with the --filter-on option puts matching actions into a multi-index map. You can then use cleos to query the map. Basically, with the history plugin, memory is your database, and it will eventually fill up.

Thanks issue has been solved :+1:
--filter-on "*" data is accessed through v1/history/get_actions or cleos get actions ..
Above worked for me in addition, with the "--filter-on" when starting nodeos, we can get the "print" output from the "traces" array located in the transaction. So if you retrieve the transaction using "rpc.history_get_transaction(transaction_id, block_num)" in your javascript code, the print statements will be in the "traces" array. See below for an output I got for a hello contract I deployed on my local chain. See "traces" and "console" below for the hello statement.
