Smart Contract Interaction
Now that you have deployed the Hello World smart contract on the Tron blockchain. You can interact with your contract by calling functions defined in HelloWorld.sol in Tron-IDE.
Note
Enter the contract address (TAbsq7DzmrFriHZ5Vk2cK4npCcYPvtWhZ8) into At Address to call smart contract functions.
The contract contains two functions: postMessage
and getMessage
.
The postMessage
function is state-changing because it changes the message variable within the contract. The calling of this function needs a signature and consumes energy. The getMessage
function is read-only, it only returns the message variable (reading the contract, not changing the state) and no signature or resources consume is needed.
A successful call of getMessage
returns the id and contract_result and the transaction receipt. The id is the hash of the transaction broadcasted to the blockchain, and the contract_result is the output of the function call. The getMessage
function returns the variable message, it's an empty string in this example. You can make a change that by calling postMessage
.
You have successfully created, compiled, deployed, and interacted the HelloWorld smart contract on the TRON blockchain. Congratulations!
Updated over 4 years ago