Hush Smart Chain Creator https://hush.is/hsc-creator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

8.8 KiB

Creating Hush Smart Chains

Introduction

Requirements for Creating a New Chain

  • 2 nodes (a node can be either a physical computer or a VPS)
    • It's best for the node which mines your genesis block to be a physical computer, since it will have access to potentially a lot of funds. Do not trust a VPS with your funds!
    • Only one node needs a public IP address.
  • At least 4GB RAM each
  • At least 2 CPU cores each
  • 64-bit Operating System (Ubuntu 18.04 recommended)
  • Hush Smart Chain software installed on each

Basic Info for Connecting At Least Two Nodes

Basic knowledge about how to connect two nodes is recommended for the initial setup.

As per the original blockchain designs of Satoshi Nakamoto, a Hush Smart Chain does not exist on a single node. Rather, it exists via a connection between two or more nodes. This is the nature of decentralization: it is on the network we rely, rather than a single authority. Therefore, the design of the technology encourages the developer to have two separate nodes which are able to connect over a network.

In the most ideal circumstance, the new Hush developer will already have two virtual private servers (VPS's) available for testing. VPS's can be cheap and easy to manage. A typical VPS will either have a static external IP or can be assigned one.

If the new developer does not have two VPS's available, setting up a test Hush Smart Chain on two local machines in a home or office-type setting is still achievable, but it may require more troubleshooting.

When using a home or office-type setup, the challenge lies in the way the network is created, and there are myriad network setups.

For example, if the developers are operating on a local router, where the two machines are connected via wifi, the local ip addresses of the machines are harder to find. This is because the router assigns new local ip addresses to the machines each time they re-connect to the router. It is not possible to see the ip addresses from the Internet. In this situation, the developer must log into the router's software interface and search for the currently assigned local ip addresses.

To test the creation of a Smart Chain using only a single node, use the -testnode=1 parameter. This is good for a simple test, but two nodes should be used for rigorous testing that would simulate the network more correctly.

To prepare for the next step, execute the following command in the terminal on both machines:

curl ifconfig.me

From the response, record the ip address value for additional use.

With the ip addresses available, we are now prepared to test the connection between the machines.

ping <insert the ip address of the other machine here>

This command will generate a response every second, indicating the ping speed with which your machines are able to connect.

$ ping 192.168.1.101
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=131 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=2.40 ms

If you do not see a similar response in the shell, your machines are not able to connect (or ping is prevented via firewall).

Part I: Creating A Hush Smart Chain

With your machines successfully able to ping each other, you are ready to create your first Hush Smart Chain!

The following instructions use the simplest possible set of parameters in creating a new Smart Chain: a coin wit h the ticker symbol LULZ, 55555 pre-mined coins, and a block reward of .0001, the default.

On your first node, change into the directory where Hush's hushd and hush-cli are installed and execute the following commands in the terminal:

./hush-smart-chain -ac_name=LULZ -ac_supply=55555 &

To create a Hush Smart Chain with z2z (shielded transactions only) you add the -ac_private=1 param:

./hush-smart-chain -ac_name=LULZ -ac_private=1 -ac_supply=55555 &

Remember to use the exact same parameters on both nodes, or they will not be able to connect to each other, because they will be different, incompatible blockchains. All parameters that start with -ac_ must match exactly for the same RPC port and other details to match.

By default, a Proof-of-Work algorithm of Equihash (200,9) is used, which is compatible with existing ASICs that are used to mine HUSH, ZEC, ZEN and a few other cryptocoins. To use a CPU mining algorith, use randomx like this:

./hush-smart-chain -ac_name=LULZ -ac_private=1 -ac_algo=randomx -ac_supply=55555 &

**For other -ac_ parameters to use with your Hush Smart Chain, refer to hsc-options-explained.md.**

Verify the Response

After issuing this command in the terminal on both machines, you will find the p2p port in the terminal window.

>>>>>>>>>> LULZ: p2p.6969 rpc.6970 magic.c89b00b16 3365559062 55555 coins

In the above string, take note of the p2p and RPC ports, as well as the magic number. These values must match on both nodes for the chains to be identical. If they are not the same, verify that the launch command is the same on both the nodes.

In the example above, the p2p port is 6969. Make sure that the p2p port is open to the internet or any other network from which the second node connects.

This completes the first half of the Smart Chain creation process.

Part II: Connecting the Second Node

On the second node you issue the same command, but with a key difference. This time, use the first node's IP address.

./hush-smart-chain -ac_name=LULZ -ac_supply=55555 -gen -genproclimit=1 -addnode=1.2.3.4 &

where you replace 1.2.3.4 with the IP of your first node.

Once the daemon loads, compare the string that starts with >>>>>>>>>> in the second node to the one from the first node to make sure they are identical.

The arguments -gen -genproclimit=1 enables mining on this node with 1 CPU thread. The genesis block should be mined with 1 thread to avoid issues. Once the genesis block (genblock) is mined, you can increase the number of CPU threads it uses with:

./hush-cli -ac_name=LULZ setgenerate true 1

to mine with 2 CPU threads. Mining with too many threads will likely degrade performance of your VPS, make sure to leave at least 1 CPU thread not mining, so the operating system and other processes have resources.

On a Hush-based blockchain, all of the pre-mined coins are mined in block 1. Therefore, whichever machine executes the mining command will receive the entirety of the blockchain's pre-mined coin supply, as set in the ac_supply parameter. Upon mining the first block, these coins are available in the default wallet.dat file. Use getwalletinfo to see the balance.

To collect all the mining rewards from the node to a single address, execute the following commands before issuing the setgenerate command:

# Get a new address
newaddress=$(./hush-cli -ac_name=LULZ getnewaddress)

# Get the corresponding pubkey
pubkey=$(./hush-cli -ac_name=LULZ validateaddress $newaddress | jq -r '.pubkey' )

# Indicate the pubkey to the daemon
./hush-cli -ac_name=LULZ setpubkey $pubkey

After enabling mining, you can check that the two nodes are connected by using the following command:

./hush-cli -ac_name=LULZ getinfo | grep connections

If the nodes are properly connected, both nodes will respond with: "connections": 1 .

You can get more detailed info about connections with hush-cli -ac_name=LULZ getpeerinfo .

These are the coins you will later distribute to your community or use for HushChat or whatever other fun stuff you have planned 😄

You can check the contents of the wallet by executing the following command in the terminal:

./hush-cli -ac_name=LULZ getwalletinfo

Querying the Smart Chain

Using the hush-cli software, which is included in any default installation of hushd, you can now execute many commands on your new Smart Chain. This enables you to perform transactions, create and execute smart contracts (if they are enabled on your HSC) and use HushChat protocol and applications.

Since the Hush codebase long ago forked from Zcash (which forked from Bitcoin), essentially all commands that are available on these two upstream blockchains are also available on your new Smart Chain.

Example commands

To see general information about your new Smart Chain, execute this command:

./hush-cli -ac_name=LULZ getinfo

The following command returns information about all available RPC and API commands:

./hush-cli -ac_name=LULZ help

Copyright

The Hush developers

License

GPLv3