Skip to content

Latest commit

 

History

History
74 lines (45 loc) · 4.36 KB

README.md

File metadata and controls

74 lines (45 loc) · 4.36 KB

Simple App

Simple app is a Java application that runs a basic Sidechain Node, able to receive and send coins from/to the mainchain ("Forward" and "Backward transfers"). It does not come with any application-specific code (e.g. custom boxes or transactions); that logic can be easily added to Simple App, and implement that way a complete, blockchain based distributed application.

Simple App node(s) can also be run without a connection to mainchain.

Execution

You can run Simple App inside an IDE by just executing the SimpleApp class in the examples/simpleapp module.

Otherwise, to run SimpleApp outside the IDE:

  1. Build and package the project
    mvn package
    
  2. Go to the project root directory and execute in a command line:
    • (Windows)
      cd Sidechains-SDK\examples\simpleapp
      java -cp ./target/sidechains-sdk-simpleapp-0.2.5.jar;./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
      
    • (Linux)
      cd ./Sidechains-SDK/examples/simpleapp
      java -cp ./target/sidechains-sdk-simpleapp-0.2.5.jar:./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
      
      On some Linux OSs during backward transfers certificates proofs generation a extremely big RAM consumption may happen, that will lead to the process force killing by the OS. While we keep monitoring the memory footprint of the proofs generation process, we have verified that setting the glibc per-thread cache with the following command 'export GLIBC_TUNABLES=glibc.malloc.tcache_count=0' just before starting the sidechain node in order keeps the memory consumption in check.

Running Simple App isolated from Mainchain

You can use the predefined sc_settings.conf configuration file, which contains some genesis data that will start a node with a first mainchain block reference and some coins transferred to the sidechain.

Since there will be no real mainchain node running, with the mainchain block reference included by the genesis just made up, the sidechain will not receive any subsequent mainchain information; the sidecahin will run stand-alone, "isolated".

Such a configuration is useful to test a sidechain's logic and behaviour, without any interaction with the mainchain network.

Running Simple App connected to a Mainchain node

This configuration allows the full use of sidechain node functionalities, i.e. create new sidechains, synchronize a sidechain with the mainchain (i.e. mainchain block references are included in sidechain blocks), transfer coins from/to mainchain and vice versa. Please find here a detailed guide on how to setup up this complete configuration.

How to choose the address of the first forward transfers

The sc_create RPC method specifies two public keys, that are part of the Vrf and the ed25519 keypairs. To generate a new pair of secret-public keys, you can use the generatekey and generateVrfKey ScBootstrappingTool commands: e.g. generatekey {"seed":"myuniqueseed"} and generateVrfKey {"seed":"my seed"}

Then you can put the newly generated public keys as destinations in sc_create, and the secret ones into the configuration file, in the wallet.genesisSecrets section.

Please note: if you do not specify genesisSecrets properly, you will not see that balance in the wallet.

How to choose the secret in ScBootstrapping genesisinfo command Just use a secret generated by the generatekey command.

Sidechain-related RPC commands in Mainchain

  1. sc_create withdrawalEpochLength "address" amount "verification key" "vrfPublickKey" "genSysConstant" - to create a new sidechain, please refer to example for more details.
  2. sc_send "scid" "address" amount "sidechainId" - to send a single forward transfer to a specific address in a sidechain.
  3. sc_sendmany [{"address":... ,"amount":...,"scid":,...},...] - to send multiple transfers to different addresses/sidechains.

For more info please check the horizen mainchein ("zend") repository and guides.

Sidechain HTTP API

The node API address is specified in the configuration file, network.bindAddress section. The description of all basic API, with examples, is available as a simple web interface; just type network.bindAddress in any browser to access it.