hello_wasm.sol

Overview

This file defines a smart contract named helloWorld written in Solidity with Gosh-specific extensions. The contract primarily demonstrates interactions with the blockchain environment, including token conversions, WASM execution, contract deployment, and token transfers within the same or different decentralized application (Dapp) IDs. It also maintains a timestamp reflecting the last interaction time with the contract. The contract leverages low-level TVM (TON Virtual Machine) instructions and Gosh-specific functions to handle token operations and WASM runtime calls.


Contract: helloWorld

State Variables


Constructor

constructor(uint64 value)

Initializes the contract by converting the specified amount of SHELL tokens to VMSHELL tokens, checks the contract's public key, accepts the deployment message for processing, and sets the timestamp to the current block time.


Functions

exchangeToken

function exchangeToken(uint64 value) public pure

Converts a given amount of SHELL tokens to VMSHELL tokens.


renderHelloWorld

function renderHelloWorld () public pure returns (string)

Returns a fixed string "helloWorld".


runWasm

function runWasm(bytes wasmBinary, string wasmModule, string wasmFunction, bytes wasmArgs, bytes wasmHash) public returns (bytes)

Executes a WASM binary module function with provided arguments and returns the result bytes.


runWasmConcatMultiarg

function runWasmConcatMultiarg(bytes wasmBinary, string wasmModule, string wasmFunction, bytes wasmArgs, bytes wasmArgs2, bytes wasmArgs3, bytes wasmArgs4, bytes wasmHash) public returns (bytes)

Executes a WASM function with multiple concatenated arguments.


touch

function touch() external

Updates the timestamp variable with the current block time. This function can be called externally.


callExtTouch

function callExtTouch(address addr) public view

Calls the touch method of another contract via an internal message.


sendVMShell

function sendVMShell(address dest, uint128 amount, bool bounce) public view

Transfers VMSHELL tokens to another contract within the same Dapp ID.


sendShell

function sendShell(address dest, uint128 value) public view

Transfers SHELL tokens to a specified address, which can be within the same or a different Dapp ID.


deployNewContract

function deployNewContract(TvmCell stateInit, uint128 initialBalance, TvmCell payload) public pure

Deploys a new contract within the same Dapp by specifying its initial state and funding.


getTokens

function getTokens() private pure

Checks if the contract balance is below 100 VMSHELL and mints tokens if necessary.


Cell Creation Functions

These functions demonstrate creation of complex and nested TvmCell structures for data storage or processing.


Interface: IHelloWorld

Defines an external interface with one function:

function touch() external;

Used to call the touch() function on other contracts that implement this interface.


Important Implementation Details


Interactions with Other Parts of the System


Mermaid Diagram: Contract Structure

classDiagram
class helloWorld {
+uint32 timestamp
+bytes wasmResSaved
+constructor(uint64)
+exchangeToken(uint64)
+renderHelloWorld() string
+runWasm(bytes, string, string, bytes, bytes) bytes
+runWasmConcatMultiarg(bytes, string, string, bytes, bytes, bytes, bytes, bytes) bytes
+touch()
+callExtTouch(address)
+sendVMShell(address, uint128, bool)
+sendShell(address, uint128)
+deployNewContract(TvmCell, uint128, TvmCell)
-getTokens()
+create_cell() TvmCell
+create_big_cell2(uint256) TvmCell
+create_big_cell(uint256) TvmCell
+create_deep_cell(uint256) TvmCell
}
helloWorld ..> IHelloWorld : uses

This diagram illustrates the helloWorld contract's key methods and properties, as well as its usage of the external interface IHelloWorld.