6. Interact with the contract - Call

  1. Within the scripts folder, create a file called getMessage.js

  1. Let's write our getMessage.js script

  • Import hardhat and swisstronikJS functions

  • Let's use sendShieldedQuery to send a call/query to the blockchain

  • Write the main script to use sendShieldedQuery function

  • Add this by hardhat default

  1. Execute the following command in your terminal to run the script using the Swisstronik network

npx hardhat run scripts/getMessage.js --network swisstronik

  1. Upon successful execution, your terminal should display Decoded response: Hello Swisstronik!! or the latest message you've defined in the contract 🎉

Last updated