(image)

Programming Hotmoka
A tutorial on Hotmoka and smart contracts in Takamaka

2.3 Contacting a Hotmoka node

The examples in this book must be run against a Hotmoka node, typically part of a Hotmoka blockchain. We will show you in a later chapter how you can install your own local node or blockchain. However, for now, it is much simpler to experiment with a node that is part of one of the public test blockchains that we provide for experimentation. Namely, we have installed two Hotmoka nodes for testing, of two distinct blockchains, at URIs ws://panarea.hotmoka.io:8001 and ws://panarea.hotmoka.io:8002, respectively. The peculiarity of these nodes is that they include a faucet, that is, an account that gives away small amounts of coins, when requested. This is good for experimentation but, of course, a real node will not include a faucet. In a real node, people must grasp some coins because they have been earned through mining, sent by some other user or bought from some exchange.

You can verify that you can contact the test node by typing the command moka nodes manifest show --uri ws://panarea.hotmoka.io:8001 to print the manifest of the Hotmoka node at ws://panarea.hotmoka.io:8001. The result should be something like:

|-- takamaka code: 68e90e2868751a3f22fd5fad3ceef377b91b3e52fdd30705f57505e22902ce40
`-- manifest: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#0
   |-- genesis time: 2026-02-02T18:40:59.939279412Z
   |-- chain id: octopus
   |-- max dependencies: 20
   |-- max cumulative size of dependencies: 1000000
   |-- max request size: 500000
   |-- allows unsigned faucet: true
   |-- skips verification: false
   |-- signature: ed25519
   |-- gamete: 1475f3e87d09952279f771b53c061f8136576dcf5c1e6cb56e84eef7bcefc95e#0
   | |-- balance: 9999999999999996999996431257
   | `-- max faucet: 10000000000000000
   |-- gas station: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#e
   | |-- initial gas price: 100
   | |-- gas price: 6
   | |-- max gas per transaction: 10000000
   | |-- ignores gas price: false
   | |-- target gas at reward: 1000000
   | `-- oblivion: 250000 (ie. 25.00%)
   |-- validators: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#1
   | |-- number of validators: 0
   | |-- initial supply: 10000000000000000000000000000
   | |-- current supply: 10004873707697796497563725185
   | |-- final supply: 1000000000000000000000000000000
   | |-- height at final supply: 42048000
   | |-- height: 69
   | |-- number of transactions: 7
   | |-- ticket for new poll: 100000
   | `-- number of polls: 0
   |-- initial validators: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#c
   | `-- number of initial validators: 0
   |-- accountsLedger: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#f
   `-- versions: b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#d
      `-- verificationVersion: 0

The details of this information are irrelevant for now, but something must be clarified, to better understand the following sections. Namely, the moka nodes manifest show command reports information that tells us that the node already contains some code and some Java objects, as shown in Fig. 2.3.

(-tikz- diagram)

Figure 2.3: Manifest, gamete, gas station and validators.

The Takamaka code reference is the pointer to a jar, installed in blockchain, that contains the classes of the Takamaka language runtime. All programs that we will write in Takamaka will depend on that jar, directly or indirectly, since they will use classes such as io.takamaka.code.lang.Contract or annotations such as io.takamaka.code.lang.View. The manifest reference, instead, points to a Java object that publishes information about the node. Namely, it reports its chain identifier and the signature algorithm that, by default, is used to sign the transactions for the node. The manifest refers to another object, called gamete, that is an account holding all the initial coins, if any. Consequently, the gamete may have a rich balance property, but also another interesting property, called max faucet, that states how much coins the faucet is willing to give up for free at each transaction. In a real node, and differently from here, that value should be zero. In this test network, instead, it is a non-zero value that we will exploit for creating our first account, in a moment. The manifest refers also to a gas station, that it, to another Java object that provides information about the gas, such as its current price. Finally, the manifest refers to another Java object, called validators, that keeps information about the validator nodes of the network, if the network has validators: in the case of ws://panarea.hotmoka.io:8001 there are no validators, since that network is based on a completely decentralized proof of space consensus, without special validator nodes. The validators object contains, in any case, also the initial, current and final supply of cryptocurrency (how much cryptocurrency was minted at the beginning of the network, has much has been minted up to now, and how much will exist eventually).

As we said before, Java objects in the Hotmoka node are identified by their storage reference, such as b5afa05ba88ad64fdc75750f5ce7744aad0e60724049c9a34587009aaf6bd01d#e. You can think at a storage reference as a machine-independent pointer inside the memory, or state, of the node.

We have used the moka command to see the manifest of a node. You can also use the Mokito app for that. Namely, tap on the app menu icon on the top-left corner of the screen and select Manifest from the menu that will appear (see Fig. 2.4a).

(image)

(a) The menu of the Mokito app.

(image)

(b) The manifest of the Hotmoka node.
Figure 2.4: From the top-level corner menu of Mokito, it is possible to select the Manifest item to show the manifest of the Hotmoka node.

After tapping on Manifest, a new screen will appear, containing the same information that we saw with the command moka nodes manifest show (see Fig. 2.4b).