Categorygithub.com/Qitmeer/qng
module
1.2.0
Repository: https://github.com/qitmeer/qng.git
Documentation: pkg.go.dev

# README

qng

The next generation of the Qitmeer network implementation with the plug-able VMs under the MeerDAG consensus.

Installation

make sure you have go-lang version 1.21.x or above (1.22.x is recommended) installed on the system to build.

  • Build from source
~ git clone https://github.com/Qitmeer/qng.git
~ cd qng
~ make

or

or

  • Build with Docker:
~ docker build -t qng .

Make sure you have enough memory

Note : Swap 4G+ is required for running the mainent node otherwise you might need the 8G physical memory.

Ex: How to setup a 4G+ swap file on an ubuntu machine

  1. setup the swap file
sudo apt update
sudo apt install --reinstall util-linux
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
  1. check the running swap file
sudo swapon -s
  1. edit /etc/fstab file (optional)
sudo vi /etc/fstab

add a line to the end of /etc/fstab file

/swapfile swap swap defaults 0 0

Getting Started

  • We take the construction of test network nodes as an example:
~ cd ./build/bin
~ ./qng --testnet
~ docker run --rm -it --name qng qng:latest ./build/bin/qng --mixnet --acceptnonstd --modules=qitmeer --modules=p2p

Miner

  • If you are a miner, you also need to configure your reward address:
~ ./qng --testnet --miningaddr=Tk6uXJ3kjh3yA4q94KQF9DTL14rDbd4vb2kztbkfhMBziR35HYkkx 
  • Please note that the mining address here is a PK address:
~ ./qx ec-to-public [Your_Private_Key] | ./qx ec-to-pkaddr -v=testnet
  • If you use the old address(PKH Address), you will only be unable to package the cross chain transaction.

Address

Use qx Command line tools

Note: to use "qx" tool, you need to enter the directory ./cmd/qx to build the qx command, see this guide for details

  • PKH Address:
~ ./qx ec-to-public [Your_Private_Key] | ./qx ec-to-addr -v=testnet
  • PK Address:
~ ./qx ec-to-public [Your_Private_Key] | ./qx ec-to-pkaddr -v=testnet
  • MeerDAG Address:
~ ./qx ec-to-public [Your_Private_Key] | ./qx ec-to-ethaddr
or
~ ./qx pkaddr-to-public [Your_pkaddress] | ./qx ec-to-ethaddr
or
~ ./qx pkaddr-to-ethaddr [Your_pkaddress]
Use qng RPC
  • All addresses corresponding to the same private key:
~ ./cli.sh getaddresses [Your_Private_Key]

(Due to safety reasons, you need to actively open the private module by ./qng --modules=test)

MeerEVM

  • If you want to use our MeerEVM function, the required interface information can be queried in this RPC:
~ cd ./script
~ ./cli.sh vmsinfo
  • If you don't need the default configuration, we provide an environment configuration parameter to meet your custom configuration for MeerEVM:
~ ./qng --testnet --evmenv="--http"
or
~ ./qng --testnet --evmenv="--http --http.port=18545 --ws --ws.port=18546"
~ 
  • You first need to transfer your money in qitmeer to MeerEVM:createExportRawTx <txid> <vout> <PKAdress> <amount>
~ ./cli.sh createExportRawTx ce28ec92cc99b13d9f7a658d2f1e08aa9e4f27ebcfaf5344750bb77484a79657 0 Tk6uXJ3kjh3yA4q94KQF9DTL14rDbd4vb2kztbkfhMBziR35HYkkx 11000000000
~ ./cli.sh txSign [Your_Private_Key] [rawTx]
~ ./cli.sh sendRawTx [signRawTx]
  • Or you can use the multiple inputs or outputs version:createExportRawTxV2 <inputs> <outputs> <lockTime>
~ ./cli.sh createExportRawTxV2 '[{"txid":"0e6aa3a41c6712ed5d68960f2315041579767a9d0a7be9988276cc802e2ae269","vout":0},{"txid":"2d1b3e5e89fbcec54368b7d98079bf533e38f1ce48bfd752582ea87bbac5cbca","vout":0}],[{"address":"Tk6tMafZQW1r2WzwW9V8ynq2HkLhc43nPaMivHTsJGvBUHRNLycPh","amount":11000000000},{"address":"TnNbgxLpoPJCLTcsJbHCzpzcHUouTtfbP8c","amount":999900000}]' 
~ ./cli.sh txSign [Your_Private_Key] [rawTx]
~ ./cli.sh sendRawTx [signRawTx]
  • Finally, wait for the miner to pack your transaction into the block. Then you have the money to start operating your MeerEVM ecosystem.

How can I transfer my money in meerevm to the qitmeer account system ?

~ ./cli.sh createImportRawTx Tk6uXJ3kjh3yA4q94KQF9DTL14rDbd4vb2kztbkfhMBziR35HYkkx [amount] 
~ ./cli.sh txSign [Your_Private_Key] [rawTx]
~ ./cli.sh sendRawTx [signRawTx]
  • Finally, wait for the miner to pack your transaction into the block.

How to call QNG's RPC in the JavaScript runtime environment of meerevm ?

~ ./qng --testnet --evmenv="--http --http.port=18545 --http.api=net,web3,eth,qng"
~ ./qng attach http://127.0.0.1:18545

Welcome to the Geth JavaScript console!

instance: meereth/v1.10.9-stable/darwin-amd64/go1.16.2
at block: 0 (Thu Jan 01 1970 08:00:00 GMT+0800 (CST))
 datadir: /bin/data/testnet
 modules: eth:1.0 net:1.0 qng:1.0 rpc:1.0 web3:1.0

To exit, press ctrl-d or type exit
> qng.getNodeInfo
...
...

How to export the data of blocks from node

~ ./qng blockchain export
or
~ ./qng blockchain export --path=[Output directory]

How to import the data of blocks to node

~ ./qng blockchain import
or
~ ./qng blockchain import --path=[Input directory]

How to upgrade the data of blocks to node

~ ./qng --testnet blockchain upgrade

First aid mode under consensus error

~ ./qng --testnet blockchain upgrade --aidmode

# Packages

No description provided by the author
Package common contains various helper functions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
It is called by go generate and used to automatically generate pre-computed Copyright 2017-2018 The qitmeer developers This file is auto generate.
Package log15 provides an opinionated, simple toolkit for best-practice logging that is both human and machine readable.
Package dbnamespace contains constants that define the database namespaces for the purpose of the blockdag, so that external callers may easily access this data.
No description provided by the author
Package metrics provides general system and process level metrics collection.
Copyright (c) 2017-2018 The qitmeer developers.
No description provided by the author
No description provided by the author
Copyright 2017-2018 The qitmeer developers Use of this source code is governed by an ISC license that can be found in the LICENSE file.
No description provided by the author
No description provided by the author
It is called by go generate and used to automatically generate pre-computed Copyright 2017-2022 The qitmeer developers This file is auto generate by : go run compile_solidity.go .
Package trie implements Merkle Patricia Tries.
No description provided by the author
No description provided by the author