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

In this smart contract, you will change the value stored in the contract memory and synchronize all nodes to have the same contract memory.


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, obtain the value stored in the smart contract by executing the getGreeting function:

tymlez-sc call --functionName=getGreeting

A greeting will then be returned:

[INFO] - { result: 'Hello' }

Now, change the value stored in the smart contract:

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 value has changed:

tymlez-sc call --functionName=getGreeting

You should now see the updated value::

[INFO] - { result: 'HelloWorld' }

Return to the smart contracts main page