Revoke Document
Summary:
The script executes a transaction on a smart contract deployed on the Hedera network to revoke a seal using a specific hash. It showcases how to send transactions to the smart contract and process the transaction receipts and event logs emitted by the contract.
1. Imports and Environment Setup:
const {
Client,
ContractFunctionParameters,
ContractExecuteTransaction,
PrivateKey
} = require("@hashgraph/sdk");
require('dotenv').config({ path: 'SmartContract_Service/.env' });
const Web3 = require('web3');
const web3 = new Web3;
let abi;It imports necessary modules from the Hedera JavaScript SDK (
@hashgraph/sdk) and thedotenvmodule to load environment variables from a.envfile located in theSmartContract_Servicedirectory.It imports the
Web3library to decode event logs emitted by the smart contract.
2. Environment Variables Retrieval and Validation:
It retrieves the account ID, private key, contract ID, and hash from the
.envfile.It checks whether these variables are present; otherwise, it throws an error.
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.
4. Main Function:
It defines the
main()function, which is the entry point of the script.It creates a transaction to execute the
revokeSealfunction of the smart contract with the provided hash parameter.The transaction is submitted to the Hedera network, and the result (transaction receipt) is retrieved.
Event logs emitted by the smart contract during the transaction execution are decoded using the
decodeEvent()function.
5. Event Decoding Function:
It defines the
decodeEvent()function to decode event logs emitted by the smart contract using the contract's ABI definition.
6. Execution:
This line calls the
main()function to start the execution of the script.
Last updated
Was this helpful?