Reading the Evernode STDIN with Bash

Moderator: EvrSteward

Post Reply
CoderGeeK
Posts: 8
Joined: Sat Aug 24, 2024 6:31 pm

Reading the Evernode STDIN with Bash

Post by CoderGeeK »

The hotpocket core is sending standard inputs to the evernode instance in JSON format.

With bash, you can fetch it and read it.

Here's an example where I fetch the payload and store it in a log file that is on the outside of the contract folder. (/contract/contract_fs/seed)

In this particular code I am outputting the contract id, the payload can also be outputted, if you remove the comment mark #!

Code: Select all

#!/bin/bash

output_file="../contract.log"

# Read the JSON payload from STDIN
read -r json_payload

# Dump the entire payload (like a var_dump)
#echo "Dumping entire payload:"
#echo "$json_payload" > ../payload

# Parse the contract_id from the JSON using jq and print it
contract_id=$(echo "$json_payload" | jq -r '.contract_id')

# Output the contract_id
echo "Contract ID: $contract_id" >> "$output_file"
Post Reply