Scheduled Transaction Info
Summary
This script retrieves and displays information about a scheduled transaction on the Hedera network using its schedule ID. It demonstrates how to use the ScheduleInfoQuery to query schedule information and extract relevant data such as schedule ID, memo, creator account ID, payer account ID, expiration time, and execution time.
Step 1: Imports and Environment Setup
The script imports necessary modules from the Hedera JavaScript SDK (
@hashgraph/sdk):Client,PrivateKey,ScheduleInfoQuery,Timestamp,ScheduleId,AccountId, andTransactionId.It also imports the
dotenvmodule to load environment variables from a.envfile located in theScheduled_TXdirectory.
const {
Client,
PrivateKey,
ScheduleInfoQuery,
Timestamp,
ScheduleId,
AccountId,
TransactionId
} = require("@hashgraph/sdk");
require('dotenv').config({ path: 'Scheduled_TX/.env' });Step 2 : Environment Variables Retrieval and Validation
The code retrieves necessary environment variables such as account ID and private key from the
.envfile.It validates that the required environment variables (
MY_ACCOUNT_IDandMY_PRIVATE_KEY) are present. If not, it throws an error.
Step 3: Client Setup
It creates a client instance for the Hedera testnet and sets the operator account using the user's account ID and private key.
Step 4: Main Function
It creates a
ScheduleInfoQueryinstance to retrieve information about the scheduled transaction using the provided schedule ID.The query is executed with the client to obtain the schedule information.
Information about the schedule, such as schedule ID, memo, creator account ID, payer account ID, expiration time, and execution time, is logged to the console.
Step 5: Execution
This line calls the main() function to start the execution of the script.
Last updated
Was this helpful?