hello_wasm.abi.json

Overview

The hello_wasm.abi.json file defines the Application Binary Interface (ABI) for a smart contract designed to interact with WebAssembly (WASM) binaries within a blockchain environment. The ABI specifies the contract's callable functions, their inputs and outputs, persistent storage fields, and metadata such as the ABI version and contract version.

This ABI facilitates functionalities such as executing WASM functions with various argument formats, managing tokens, deploying new contracts, and creating complex on-chain data structures called "cells." The contract maintains state variables including a public key, timestamps, and stored WASM execution results.

ABI Structure and Components

Metadata

Persistent Fields

These fields represent the contract's storage variables:

Field Name

Type

Initialization

Description

_pubkey

uint256

true

Public key associated with the contract; initialized at deployment.

_timestamp

uint64

false

Internal timestamp for contract logic.

_constructorFlag

bool

false

Flag indicating if the constructor has been executed.

timestamp

uint32

false

Publicly accessible timestamp value.

wasmResSaved

bytes

false

Stores the output bytes from the last WASM execution.


Functions

The contract exposes multiple functions with varying purposes. Each function's inputs, outputs, and usage are detailed below.

1. constructor(value: uint64)


2. exchangeToken(value: uint64)


3. renderHelloWorld() -> string


4. runWasm(wasmBinary: bytes, wasmModule: string, wasmFunction: string, wasmArgs: bytes, wasmHash: bytes) -> bytes


5. runWasmConcatMultiarg(...) -> bytes


6. touch()


7. callExtTouch(addr: address)


8. sendVMShell(dest: address, amount: uint128, bounce: bool)


9. sendShell(dest: address, value: uint128)


10. deployNewContract(stateInit: cell, initialBalance: uint128, payload: cell)


11. create_big_cell2(iterations: uint256) -> cell


12. create_big_cell(iterations: uint256) -> cell


13. create_deep_cell(iterations: uint256) -> cell


14. timestamp() -> uint32


15. wasmResSaved() -> bytes


Implementation Details and Algorithms


Interaction with Other System Components


Visual Diagram

flowchart TD
A[hello_wasm.abi.json ABI] --> B[Constructor]
A --> C[Token Management]
A --> D[WASM Execution]
A --> E[Cell Creation]
A --> F[Contract Deployment]
A --> G[Inter-contract Calls]
A --> H[Timestamp & State Access]
B --> B1["constructor(value)"]
C --> C1["exchangeToken(value)"]
C --> C2["sendVMShell(dest, amount, bounce)"]
C --> C3["sendShell(dest, value)"]
D --> D1["runWasm(...)"]
D --> D2["runWasmConcatMultiarg(...)"]
D --> D3["wasmResSaved()"]
E --> E1["create_big_cell(iterations)"]
E --> E2["create_big_cell2(iterations)"]
E --> E3["create_deep_cell(iterations)"]
F --> F1["deployNewContract(stateInit, initialBalance, payload)"]
G --> G1["callExtTouch(addr)"]
G --> G2["touch()"]
H --> H1["timestamp()"]
H --> H2["renderHelloWorld()"]

This diagram groups the contract's functions into functional categories, illustrating their relationship to the overall ABI definition. It highlights the main workflows: initialization, token handling, WASM execution, data structure creation, deployment, inter-contract communication, and state/time access.