Smart Contract #2 - Hello World Part 2 - Change memory

In this smart contract, you will update the smart contract contract memory and synchronize all nodes to have the same contract memory.


The video provides some context about the Smart Contract #2 and shows you how you can run the sample application.



In a terminal session, trigger a smart contract:

tymlez-sc publish --templateName=SC_HelloWorld_Part2 Hello

If the contract is successfully published, the system will return a valid contract ID:

[INFO] commands.publish - publishing contract SC_HelloWorld_Part2....
[INFO] commands.publish - Signed tx...
[INFO] commands.publish - Post signed tx ....
[INFO] commands.publish - Smart Contract published successfully
[INFO] commands.publish - Contract id: e4897b7a1cb6055bba7fd66c75cbb5f12420f1198938db20b8e3ef5ebe304f9

Now, read the smart contract memory by executing the getGreeting function:

tymlez-sc call --functionName=getGreeting

The memory will then be returned:

[INFO] - { result: 'Hello' }

Now, update the smart contract memory with the function changeGreeting:

tymlez-sc call --functionName=changeGreeting "HelloWorld"

The value of the smart contract has now been updated.

[INFO] - contract ID: ce4897b7a1cb6055bba7fd66c75cbb5f12420f1198938db20b8e3ef5ebe304f9
[INFO] - Signed tx...
[INFO] - Post signed tx ....
[INFO] - Smart Contract updated !!!

Verify if the memory has been updated:

tymlez-sc call --functionName=getGreeting

You should now see the updated smart contract memory:

[INFO] - { result: 'HelloWorld' }

Return to the smart contracts main page