gridcoin-community / Gridcoin-Research

Gridcoin-Research
MIT License
588 stars 173 forks source link

Console Command to Return Message. #2712

Open PrestackI opened 10 months ago

PrestackI commented 10 months ago

Feature Request

Describe the Feature Request I would like to see a console command that will return the body of a contract built into the console command list.

Command name would be "getmessage" and accept TX ID.

Describe Preferred Solution N/A

Describe Alternatives N/A

Related Code

"contracts": [
{
"version": 2,
"type": "message",
"action": "A",
"body": "Thank you! Live long and prosper!"
}
],

Additional Context Bounty = 1,450 GRC (Payable by author upon integration into main chain)

jamescowens commented 9 months ago

Why do we need this? gettransaction provides the body of any contracts in the transaction already in JSON format.

PrestackI commented 9 months ago

Unknown use cases.

Most likely fringe with limited applications.

I thought if it was built, it could be used for something.

I can close it if you don't think it is worth the effort.

PrestackI commented 9 months ago

Random Fringe Idea that comes to mind:

A script that would print the output of a Success from a process to the blockchain and then Wait until the getmessage is returned as included.

My current idea would take a total of ~40KB of space in the blockchain from ~19 days of work.

The total fees paid for the transactions would be ~1.397 GRC (~0.07352631 fees added per day).

We could probably add a flag for extra cost to store if needed.

jamescowens commented 9 months ago

It is not that it isn't worth the effort, it is that the functionality you asked for is already covered by an existing command.

My sense is that you want to use the messaging system as a stamp similar to the stamping service we have already?

If you use gettransaction and then send through jq, this will work out of the box... for example...

gridcoinresearchd gettransaction <hash> | jq -r '.contracts[]'

jamescowens commented 9 months ago

More specifically...

gridcoinresearchd gettransaction <hash>|jq -r '.contracts[]|if .type == "message" then .body else "" end'

returns the body of the contract if it is a message else returns nothing (empty string).

PrestackI commented 9 months ago

Not so much like the stamper, more of a "I found it! (here it is)" sort of recording.

That worked as expected but it does require an additional program to operate. The benefits of having it in within the console as a command line would be that it works out of the box. Perhaps maybe it would be more useful if you could call any part of the contract?

jamescowens commented 9 months ago

I don’t see a need to do this. The JSON is provided by the existing gettransaction call. jq is a ubiquitous utility provided for exactly this purpose - to parse JSON for downstream processing.

PrestackI commented 9 months ago

Acknowledged.

Closing with keywords:

Native Blockchain apps Built in console commands

PrestackI commented 7 months ago

Reopening this issue since the JSON is only parasable through the daemon and not in the native console.

"error: You must set rpcpassword= in the configuration file:"

jamescowens commented 7 months ago

I am not following your comment above?

div72 commented 7 months ago

@jamescowens I think they meant that gridcoinresearchd output can be non-JSON parsable if the return type is a string (as the quotes are not present) or if the command errored?

@PrestackI Use the RPC interface instead if you are writing a script to interact with the wallet for cases like that.

PrestackI commented 7 months ago

@jamescowens @div72 I think there is a gap in my understanding.

Is it possible to run a GUI wallet with the daemon being callable via RPC command line options?

jamescowens commented 7 months ago

Yes! Just put server=1 and set the rpc username and password in the config file.

jamescowens commented 7 months ago

Then the GUI instance will also respond to rpc requests just like a headless daemon.

PrestackI commented 6 months ago

@jamescowens I will have to retry this method and get back to you.