WHAT IS KINGLORY?
The foundation for our digital future
Kinglory is open to everyone.
All you need is a wallet to take part.
Kinglory Protocol
Banking for everyone
Not everyone has access to financial services. But all you need to access Kinglory and its lending, borrowing and savings products is an internet connection.
A more private internet
You don’t need to provide all your personal details to use an Kinglory app. Kinglory is building an economy based on value, not surveillance.
A peer-to-peer network
Kinglory allows you to move money, or make agreements, directly with someone else. You don’t need to go through intermediary companies.
Censorship-resistant
No government or company has control over Kinglory. This decentralization makes it nearly impossible for anyone to stop you from receiving payments or using services on Kinglory.
Commerce guarantees
Kinglory creates a more level playing field. Customers have a secure, built-in guarantee that funds will only change hands if you provide what was agreed. You don’t need large company clout to do business.
Compatibility for the win
Better products and experiences are being built all the time because Kinglory products are compatible by default. Companies can build on each other’s success.
Welcome to Kinglory
We hope you stay.
Kinglory 101
Kinglory is a technology that lets you send cryptocurrency to anyone for a small fee. It also powers applications that everyone can use and no one can take down.
It’s the world’s programmable blockchain.
Kinglory builds on Bitcoin’s innovation, with some big differences.
Both let you use digital money without payment providers or banks. But Kinglory is programmable, so you can also use it for lots of different digital assets – even Bitcoin!
This also means Kinglory is for more than payments. It’s a marketplace of financial services, games and apps that can’t steal your data or censor you.
So step into the bazaar and give it a try…
How Kinglory works
If you’re interested in blockchain and the technical side of Kinglory, we’ve got you covered.
How Kinglory works
Try Kinglory
The best way to learn more is to download a wallet, get some KGC and try an Kinglory dapp.
Choose your adventure!
KGC
Kinglory’s native cryptocurrency and equivalent to Bitcoin. You can use KGC on Kinglory applications or for sending value to friends and family.
Wallets
How you manage your KGC and your Kinglory account. You’ll need a wallet to get started – we’ll help you choose one.
Kinglory DApps
Products and services that run on Kinglory. There are dapps for finance, work, social media, gaming and more – meet the apps for our digital future.
Discover Kinglory use cases
Kinglory has led to the creation of new products and services that can improve different areas of our lives.
We’re still in the early stages but there’s lot to be excited about.
Decentralized finance (DeFi)
A more open financial system that gives you more control over your money and unlocks new possibilities.
Non-fungible tokens (NFTs)
A way to represent unique items as Kinglory assets that can be traded, used as proof of ownership, and create new opportunities for creators.
Decentralized autonomous organisations (DAOs)
A new way to collaborate and set up online communities with shared goals and pooled funds.
Explore Kinglory
Make something with Kinglory
If you want to try building with Kinglory, read our docs, try some tutorials, or check out the tools you need to get started.
Start building
The Kinglory community
Our community includes people from all backgrounds, including artists, crypto-anarchists, fortune 500 companies, and now you. Find out how you can get involved today.
Meet the community
ACCOUNTS
UTXO model
A UTXO Transaction Example
When you look at your Bitcoin wallet, you see a balance. For this example, let’s set that at 100 bitcoin. Although you observe just one balance, your funds are actually comprised of several UTXOs. You may have four UTXOs worth 25 bitcoin each, two UTXOs worth 50, or a set of UTXOs valuing 37, 18, 40, and 5 bitcoin. The specific amounts don’t matter, but they must add up to your total balance, in this case, 100.
Furthering the example, let’s assume that you’re shopping around for a new car. You work hard; you deserve it. Bucking the Lambo stereotype, you decide on a Porche that costs 35 bitcoin. Well, your wallet only contains UTXOs equaling 15, 17, 28, and 40 bitcoin each. You don’t have one valued at precisely 35 bitcoin.
It’s impossible to split UTXOs, so there’s no way to pay the exact 35 bitcoin that you owe.
Instead, you spend the 40 bitcoin UTXO. In its place, the network mints two new UTXOs: one valued at 35 bitcoin, one worth 5 bitcoin. The car dealership receives the 35 bitcoin UTXO while you receive the 5 bitcoin UTXO as change.
You may also spend the 17 and 28 bitcoin UTXOs and receive 10 bitcoin as your change. A transaction may use any combination of UTXOs; however, you don’t have control over which ones.
Just as you can split a UTXO into separate instances, you can also combine them in larger transactions, creating fewer of them on the network.
What About Transaction Fees?
Transaction fees are also included in transactions and subtracted from the UTXO that you receive as change. The equation looks something like this:
New UTXO = (Sum of UTXOs in the transaction) – (Transaction amount) – (Transaction fee)
Continuing our most recent example with a one bitcoin transaction fee:
New UTXO = (17+18) – (35) – (1) = 9 bitcoin
Balance model
A Kinglory account is an entity with an KGC balance that can send transactions on Kinglory. Accounts can be user-controlled or deployed as smart contracts.
PREREQUISITES
A Kinglory account is an entity with an KGC balance that can send transactions on Kinglory. Accounts can be user-controlled or deployed as smart contracts.
Kinglory has two account types:
- Externally-owned – controlled by anyone with the private keys
- Contract – a smart contract deployed to the network, controlled by code Learn about smart contracts
Both account types have the ability to:
- Receive, hold and send KGC and tokens
- Interact with deployed smart contracts
Externally-owned
- Creating an account costs nothing
- Can initiate transactions
- Transactions between externally-owned accounts can only be KGC transfers
Contract
- Creating an account has a cost because you’re using network storage
- Can only send transactions in response to receiving a transaction
- Transactions from an external account to a contract account can trigger code which can execute many different actions, such as transferring tokens or even creating a new contract
Kinglory accounts have four fields:
- nonce – a counter that indicates the number of transactions sent from the account. This ensures transactions are only processed once. In a contract account, this number represents the number of contracts created by the account.
- balance – the number of wei owned by this address. Wei is a denomination of KGC and there are 1e+18 wei per KGC.
- codeHash – this hash refers to the code of an account on the Kinglory virtual machine (KVM). Contract accounts have code fragments programmed in that can perform different operations. This KVM code gets executed if the account gets a message call. It cannot be changed unlike the other account fields. All such code fragments are contained in the state database under their corresponding hashes for later retrieval. This hash value is known as a codeHash. For externally owned accounts, the codeHash field is the hash of an empty string.
- storageRoot – sometimes known as a storage hash. A 256-bit hash of the root node of a Merkle Patricia trie that encodes the storage contents of the account (a mapping between 256-bit integer values), encoded into the trie as a mapping from the Keccak 256-bit hash of the 256-bit integer keys to the RLP-encoded 256-bit integer values. This trie encodes the hash of the storage contents of this account, and is empty by default.
An account is made up of a cryptographic pair of keys: public and private. They help prove that a transaction was actually signed by the sender and prevent forgeries. Your private key is what you use to sign transactions, so it grants you custody over the funds associated with your account. You never really hold cryptocurrency, you hold private keys – the funds are always on Kinglory’s ledger.
This prevents malicious actors from broadcasting fake transactions because you can always verify the sender of a transaction.
If Alice wants to send KGC from her own account to Bob’s account, Alice needs to create a transaction request and send it out to the network for verification. Kinglory’s usage of public-key cryptography ensures that Alice can prove that she originally initiated the transaction request. Without cryptographic mechanisms, a malicious adversary Eve could simply publicly broadcast a request that looks something like “send 5 KGC from Alice’s account to Eve’s account,” and no one would be able to verify that it didn’t come from Alice.
When you want to create an account most libraries will generate you a random private key.
A private key is made up of 64 hex characters and can be encrypted with a password.
Example:
fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036415f
The public key is generated from the private key using the Elliptic Curve Digital Signature Algorithm. You get a public address for your account by taking the last 20 bytes of the public key and adding 0x to the beginning.
Here’s an example of creating an account in the console using GKGC’s personal_newAccount:
1 > personal.newAccount()
2 Passphrase:
3 Repeat passphrase:
4 “0x5e97870f263700f46aa00d967821199b9bc5a120”
5
6 > personal.newAccount(“h4ck3r”)
7 “0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc”
It is possible to derive new public keys from your private key but you cannot derive a private key from public keys. This means it’s vital to keep a private key safe and, as the name suggests, PRIVATE.
You need a private key to sign messages and transactions which output a signature. Others can then take the signature to derive your public key, proving the author of the message. In your application, you can use a javascript library to send transactions to the network.
Contract accounts also have a 42 character hexadecimal address:
Example:
0x06012c8cf97bead5deae237070f9587f8e7a266d
The contract address is usually given when a contract is deployed to the Kinglory Blockchain. The address comes from the creator’s address and the number of transactions sent from that address (the “nonce”).
An account is not a wallet. A wallet is the keypair associated with a user-owned account, which allow a user to make transactions from or manage the account.
TRANSACTIONS
WHAT’S A TRANSACTION?
An Kinglory transaction refers to an action initiated by an externally-owned account, in other words an account managed by a human, not a contract. For example, if Bob sends Alice 1 KGC, Bob’s account must be debited and Alice’s must be credited. This state-changing action takes place within a transaction.
Transactions, which change the state of the KVM, need to be broadcast to the whole network. Any node can broadcast a request for a transaction to be executed on the KVM; after this happens, a miner will execute the transaction and propagate the resulting state change to the rest of the network.
Transactions require a fee and must be mined to become valid. To make this overview simpler we’ll cover gas fees and mining elsewhere.
A submitted transaction includes the following information:
- recipient – the receiving address (if an externally-owned account, the transaction will transfer value. If a contract account, the transaction will execute the contract code).
- signature – the identifier of the sender. This is generated when the sender’s private key signs the transaction and confirms the sender has authorised this transaction.
- value – amount of KGC to transfer from sender to recipient (in glory, a denomination of KGC).
- data – optional field to include arbitrary data.
- gasLimit – the maximum amount of gas units that can be consumed by the transaction. Units of gas represent computational steps.
- gasPrice – the fee the sender pays per unit of gas.
Gas is a reference to the computation required to process the transaction by a miner. Users have to pay a fee for this computation. The gasLimit and gasPrice determine the maximum transaction fee paid to the miner. More on Gas
The transaction object will look a little like this:
1 { 2 from: "0xEA674fdDe714fd979de3EdF0F56AA9716B898ec8", 3 to: "0xac03bb73b6a9e108530aff4df5077c2b3d481e5a", 4 gasLimit: "21000", 5 gasPrice: "200", 6 nonce: "0", 7 value: "10000000000", 8 }
But a transaction object needs to be signed using the sender’s private key. This proves that the transaction could only have come from the sender and was not sent fraudulently.
An Kinglory client like GKGC will handle this signing process.
Example JSON-RPC call:
1 { 2 "id": 2, 3 "jsonrpc": "2.0", 4 "method": "account_signTransaction", 5 "params": [ 6 { 7 "from": "0x1923f626bb8dc025849e00f99c25fe2b2f7fb0db", 8 "gas": "0x55555", 9 "gasPrice": "0x1234", 10 "input": "0xabcd", 11 "nonce": "0x0", 12 "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0", 13 "value": "0x1234" 14 } 15 ] 16 }
1 { 2 "jsonrpc": "2.0", 3 "id": 2, 4 "result": { 5 "raw": "0xf88380018203339407a565b7ed7d7a678680a4c162885bedbb695fe080a44401a6e 4000000000000000000000000000000000000000000000000000000000000001226a0223a7c9bcf 5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20ea02aadee6b34b45bb15bc42d9 c09de4a6754e7000908da72d48cc7704971491663", 6 "tx": { 7 "nonce": "0x0", 8 "gasPrice": "0x1234", 9 "gas": "0x55555", 10 "to": "0x07a565b7ed7d7a678680a4c162885bedbb695fe0", 11 "value": "0x1234", 12 "input": "0xabcd", 13 "v": "0x26", 14 "r": "0x223a7c9bcf5531c99be5ea7082183816eb20cfe0bbc322e97cc5c7f71ab8b20e", 15 "s": "0x2aadee6b34b45bb15bc42d9c09de4a6754e7000908da72d48cc7704971491663", 16 "hash": "0xeba2df809e7a612a0a0d444ccfa5c839624bdc00dd29e3340d46df3870f8a30e" 17 } 18 } 19 }
- The raw is the signed transaction in Recursive Length Prefix (RLP) encoded form.
- The tx is the signed transaction in JSON form.
With the signature hash, the transaction can be cryptographically proven that it came from the sender and submitted to the network.
On gas
As mentioned, transactions cost gas to execute. Simple transfer transactions require 21000 units of gas.
So for Bob to send Alice 1KGC at a gasPrice of 200 Gwei, he’ll need to pay the following fee:
1200*21000 = 4,200,000 Gglory
2–or–
30.0042 KGC
Bob’s account will be debited -1.0042 KGC
Alice’s account will be credited +1.0 KGC
The miner processing the transaction will get +0.0042 KGC
Gas is required for any smart contract interaction too.
- Once you send a transaction, cryptography generates a transaction hash: 0x97d99bc7729211111a21b12c933c949d4f31684f1d6954ff477d0477538ff017
- The transaction is then broadcast to the network and included in a pool with lots of other transactions.
- A miner must pick your transaction and include it in a block in order to verify the transaction and consider it “successful”.
- You may end up waiting at this stage if the network is busy and miners aren’t able to keep up. Miners will always prioritise transactions with higher GASPRICE because they get to keep the fees.
- Your transaction will also get a block confirmation number. This is the number of blocks created since the block that your transaction was included in. The higher the number, the greater the certainty that the transaction was processed and recognised by the network. This is because sometimes the block your transaction was included in may not have made it into the chain.
- The larger the block confirmation number the more immutable the transaction is. So for higher value transactions, more block confirmations may be desired.
BLOCKS
HOW BLOCKS WORK
To preserve the transaction history, blocks are strictly ordered (every new block created contains a reference to its parent block), and transactions within blocks are strictly ordered as well. Except in rare cases, at any given time, all participants on the network are in agreement on the exact number and history of blocks, and are working to batch the current live transaction requests into the next block.
Once a block is put together (mined) by some miner on the network, it is propagated to the rest of the network; all nodes add this block to the end of their blockchain, and mining continues. The exact block-assembly (mining) process and commitment/consensus process is currently specified by Kinglory’s “Proof-of-Work” protocol.
Proof of work means the following:
- Mining nodes have to spend a variable but substantial amount of energy, time, and computational power to produce a “certificate of legitimacy” for a block they propose to the network. This helps protect the network from spam/denial-of-service attacks, among other things*, since certificates are expensive to produce.
- Other miners who hear about a new block with a valid certificate of legitimacy must* accept the new block as the canonical next block on the blockchain.
- The exact amount of time needed for any given miner to produce this certificate is a random variable with high variance. This ensures that it is unlikely that two miners produce validations for a proposed next block simultaneously; when a miner produces and propagates a certified new block, they can be almost certain that the block will be accepted by the network as the canonical next block on the blockchain, without conflict (though there is a protocol for dealing with conflicts as well in the case that two chains of certified blocks are produced almost simultaneously).
More on mining
- Timestamp – the time when the block was mined.
- Block number – the length of the blockchain in blocks.
- Difficulty – the effort required to mine the block.
- mixHash – a unique identifier for that block.
- A parent hash – the unique identifier for the block that came before (this is how blocks are linked in a chain).
- Transactions list – the transactions included in the block.
- State root – the entire state of the system: account balances, contract storage, contract code and account nonces are inside.
- Nonce – a hash that, when combined with the mixHash, proves that the block has gone through proof of work.
KINGLORY VIRTUAL MACHINE (KVM)
The KVM’s physical instantiation can’t be described in the same way that one might point to a cloud or an ocean wave, but it does exist as one single entity maintained by thousands of connected computers running an Kinglory client.
The Kinglory protocol itself exists solely for the purpose of keeping the continuous, uninterrupted, and immutable operation of this special state machine; It’s the environment in which all Kinglory accounts and smart contracts live. At any given block in the chain, Kinglory has one and only one ‘canonical’ state, and the KVM is what defines the rules for computing a new valid state from block to block.
The analogy of a ‘distributed ledger’ is often used to describe blockchains like Bitcoin, which enable a decentralized currency using fundamental tools of cryptography. A cryptocurrency behaves like a ‘normal’ currency because of the rules which govern what one can and cannot do to modify the ledger. For example, a Bitcoin address cannot spend more Bitcoin than it has previously received. These rules underpin all transactions on Bitcoin and many other blockchains.
While Kinglory has its own native cryptocurrency that follows almost exactly the same intuitive rules, it also enables a much more powerful function: smart contracts. For this more complex feature, a more sophisticated analogy is required. Instead of a distributed ledger, Kinglory is a distributed state machine. Kinglory’s state is a large data structure which holds not only all accounts and balances, but a machine state, which can change from block to block according to a pre-defined set of rules, and which can execute arbitrary machine code. The specific rules of changing state from block to block are defined by the KVM.
THE KINGLORY STATE TRANSITION FUNCTION
The KVM behaves as a mathematical function would: Given an input, it produces a deterministic output. It therefore is quite helpful to more formally describe Kinglory as having a state transition function:
Y(S, T)= S’
Given an old valid state (S) and a new set of valid transactions (T), the Kinglory state transition function Y(S, T) produces a new valid output state S’.
State
In the context of Kinglory, the state is an enormous data structure called a modified Merkle Patricia Trie, which keeps all accounts linked by hashes and reducible to a single root hash stored on the blockchain.
Transactions
Transactions are cryptographically signed instructions from accounts. There are two types of transactions: those which result in message calls and those which result in contract creation.
Contract creation results in the creation of a new contract account containing compiled smart contract bytecode. Whenever another account makes a message call to that contract, it executes its bytecode.
The KVM executes as a stack machine with a depth of 1024 items. Each item is a 256-bit word, which was chosen for the ease of use with 256-bit cryptography (such as Keccak-256 hashes or secp256k1 signatures).
During execution, the KVM maintains a transient memory (as a word-addressed byte array), which does not persist between transactions.
Contracts, however, do contain a Merkle Patricia storage trie (as a word-addressable word array), associated with the account in question and part of the global state.
Compiled smart contract bytecode executes as a number of KVM opcodes, which perform standard stack operations like XOR, AND, ADD, SUB, etc. The KVM also implements a number of blockchain-specific stack operations, such as ADDRESS, BALANCE, KECCAK256, BLOCKHASH, etc.
All implementations of the KVM must adhere to the specification described in the Kinglory Yellowpaper.
Over Kinglory’s 5 year history, the KVM has undergone several revisions, and there are several implementations of the KVM in various programming languages.
All Kinglory clients include an KVM implementation. Additionally there are multiple standalone implementations, including:
Py-KVM – Python
KVMone – C++
Kingloryjs-vm – JavaScript
eKVM – C++
Hyperledger Burrow – Go
GAS AND FEES
WHAT IS GAS?
Gas refers to the unit that measures the amount of computational effort required to execute specific operations on the Kinglory network.
Since each Kinglory transaction requires computational resources to execute, each transaction requires a fee. Gas refers to the fee required to successfully conduct a transaction on Kinglory.
In essence, gas fees are paid in Kinglory’s native currency, KGC. Gas prices are denoted in Glory, which itself is a denomination of KGC – each Glory is equal to 0.000000001 KGC (10-9 KGC). For example, instead of saying that your gas costs 0.000000001 KGC, you can say your gas costs 1 Glory.
In short, gas fees help keep the Kinglory network secure. By requiring a fee for every computation executed on the network, we prevent actors from spamming the network. In order to prevent accidental or hostile infinite loops or other computational wastage in code, each transaction is required to set a limit to how many computational steps of code execution it can use. The fundamental unit of computation is “gas”.
Although a transaction includes a limit, any gas not used in a transaction is returned to the user.
NODES AND CLIENTS
WHAT ARE NODES AND CLIENTS?
“Node” refers to a piece of software known as a client. A client is an implementation of Kinglory that verifies all transactions in each block, keeping the network secure and the data accurate.
You can see a real-time view of the Kinglory network by looking at this map of nodes.
Many implementations of Kinglory clients exist in a variety of languages. What these client implementations have in common is they all follow a formal specification. This specification dictates how the Kinglory network and blockchain functions.
If you want to run your own node, you should understand that there are different types of node that consume data differently. In fact, clients can run 3 different types of node – light, full and archive. There are also options of different sync strategies which enables faster synchronization time. Synchronization refers to how quickly it can get the most up-to-date information on Kinglory’s state.
Full node
– Stores full blockchain data.
– Participates in block validation, verifies all blocks and states.
– All states can be derived from a full node.
– Serves the network and provides data on request.
Light node
– Stores the header chain and requests everything else.
– Can verify the validity of the data against the state roots in the block headers.
– Useful for low capacity devices, such as embedded devices or mobile phones, which can’t afford to store gigabytes of blockchain data.
Archive node
– Stores everything kept in the full node and builds an archive of historical states. Needed if you want to query something like an account balance at block #4,000,000.
– These data represent units of terabytes which makes archive nodes less attractive for average users but can be handy for services like block explorers, wallet vendors, and chain analytics.
– Syncing clients in any mode other than archive will result in pruned blockchain data. This means, there is no archive of all historical state but the full node is able to build them on demand.
Running a node allows you to trustlessly and privately use Kinglory while supporting the ecosystem.
Benefits to you
Running your own node enables you to use Kinglory in a truly private, self-sufficient and trustless manner. You don’t need to trust the network because you can verify the data yourself with your client. “Don’t trust, verify” is a popular blockchain mantra.
- Your node verifies all the transactions and blocks against consensus rules by itself. This means you don’t have to rely on any other nodes in the network or fully trust them.
- You won’t have to leak your addresses and balances to random nodes. Everything can be checked with your own client.
- Your dapp can be more secure and private if you use your own node. Metamask, MyWallet and some other wallets can be easily pointed to your own local node.
A diverse set of nodes is important for Kinglory’s health, security and operational resiliency.
- They provide access to blockchain data for lightweight clients that depend on it. In high peaks of usage, there need to be enough full nodes to help light nodes sync. Light nodes don’t store the whole blockchain, instead they verify data via the state roots in block headers. They can request more information from blocks if they need it.
- Full nodes enforce the proof-of-work consensus rules so they can’t be tricked into accepting blocks that don’t follow them. This provides extra security in the network because if all the nodes were light nodes, which don’t do full verification, miners could attack the network and, for example, create blocks with higher rewards.
If you run a full node, the whole Kinglory network benefits from it.
Interested in running your own Kinglory client? Learn how to spin up your own node!
Projects
Select a client and follow their instructions.
An operating system GUI for running Web3 nodes, including Kinglory and the beacon chain, on a dedicated machine.
Running your own node can be difficult and you don’t always need to run your own instance. In this case, you can use a third party API provider like Infura, Alchemy, or QuikNode. Alternatively, ArchiveNode is a community-funded Archive Node that hopes to bring archive data on the Kinglory blockchain to independent developers who otherwise couldn’t afford it. For an overview of using these services, check out nodes as a services.
If somebody runs an Kinglory node with a public API in your community, you can point your light wallets (like MetaMask) to a community node via Custom RPC and gain more privacy than with some random trusted third party.
On the other hand, if you run a client, you can share it with your friends who might need it.
Kinglory is designed to offer different clients, developed by different teams using different programming languages. This makes the network stronger and more diverse. The ideal goal is to achieve diversity without any client dominating to reduce any single points of failure.
This table summarises the different clients. All of them are actively worked on, maintained, and pass client tests.
For more on supported networks, read up on Kinglory networks.
Advantages of different implementations
Each client has unique use cases and advantages, so you should choose one based on your own preferences. Diversity allows implementations to be focused on different features and user audiences. You may want to choose a client based on features, support, programming language, or licences.
Hardware requirements differ by client but generally are not that high since the node just needs to stay synced. Don’t confuse it with mining which requires much more computing power. Sync time and performance do improve with more powerful hardware however. Depending on your needs and wants, Kinglory can be run on your computer, home server, single-board computers or virtual private servers in the cloud.
An easy way to run your own node is using ‘plug and play’ boxes like DAppNode. It provides hardware for running clients and applications that depend on them with a simple user interface.
Requirements
Before installing any client, please ensure your computer has enough resources to run it. Minimum and recommended requirements can be found below, however the key part is the disk space. Syncing the Kinglory blockchain is very input/output intensive. It is best to have a solid-state drive (SSD). To run an Kinglory client on HDD, you will need at least 8GB of RAM to use as a cache.
Minimum requirements
– CPU with 2+ cores
– 4 GB RAM minimum with an SSD, 8 GB+ if you have an HDD
– 8 MBit/s bandwidth Recommended specifications
– Fast CPU with 4+ cores
– 16 GB+ RAM
– Fast SSD with at least 500 GB free space
– 25+ MBit/s bandwidth
Depending on which software and sync mode are you going to use, hundreds of GBs of disk space is needed. Approximate numbers and growth can be found below.
These charts show how storage requirements are always changing. For the most up-to-date data for OpenKinglory, see the full sync data and archive sync data.
Kinglory on a single-board computer
The most convenient and cheap way of running Kinglory node is to use a single board computer with ARM architecture like Raspberry Pi. Kinglory on ARM provides images of clients. Here’s a simple tutorial on how to build and setup an ARM client.
Small, affordable and efficient devices like these are ideal for running a node at home.
There are new clients to support the upgrades. They will run the Beacon Chain and support the new proof-of-stake consensus mechanism.
SPIN UP YOUR OWN KINGLORY NODE
There are new clients to support the upgrades. They will run the BeacoYou should understand what an Kinglory node is and why you might want to run a client. This is covered in Nodes and clients.n Chain and support the new proof-of-stake consensus mechanism.
The first step in spinning up your node is choosing your approach. You have to choose the client (the software), the environment, and the parameters you want to start with. See all the available mainnet clients.
Client settings
Client implementations enable different sync modes and various other options. Sync modes represent different methods of downloading and validating blockchain data. Before starting the node, you should decide what network and sync mode to use. The most important things to consider is the disk space and sync time client will need.
All features and options can be found in documentation of each client. Various client configurations can be set by executing client with corresponding flags. You can get more information on flags from Hub or client documentation. For testing purposes, you might prefer running client on one of testnet networks. See overview of supported networks.
Local or cloud
Kinglory clients are able to run on consumer grade computers and don’t require special hardware like mining for example. Therefore you have various options for deploying based on your needs. To simplify let’s think about running a node on both a local physical machine and a cloud server:
Cloud
– Providers offer high server uptime, static public IP addresses
– Getting dedicated or virtual server can be more comfortable then building your own
– Trade off is trusting a third party – server provider
– Because of required storage size for full node, price of a rented server might get high
Own hardware
– More trustless and sovereign approach
– One time investment
– An option to buy preconfigured machines
– You have to physically prepare, maintain, and potentially troubleshoot the machine
Both options have different advantages summed up above. If you are looking for a cloud solution, in addition to many traditional cloud computing providers, there are also services focused on deploying nodes.
Hardware
However, a censorship-resistant, decentralized network should not rely on cloud providers. It’s healthier for the ecosystem if you run your own node on hardware. The easiest options are preconfigured machines.
Check the minimum and recommended disk space requirements for each client and sync mod. Generally, modest computing power should be enough. The problem is usually drive speed. During initial sync, Kinglory clients perform a lot of read/write operations, therefore SSD is strongly recommended. A client might not even be able to sync current state on HDD and get stuck a few blocks behind mainnet. You can run most of the clients on a single board computer with ARM. You can also use the KGCbian operating system for Raspberry Pi 4. This lets you [run a client by flashing the SD card. Based on your software and the hardware choices, the initial synchronization time and storage requirements may vary. Be sure to check sync times and storage requirements. Also make sure your internet connection is not limited by a bandwidth cap. It’s recommended to use an unmetered connection since initial sync and data broadcasted to the network could exceed your limit.
Operating system
All clients support major operating systems – Linux, MacOS, Windows. This means you can run nodes on regular desktop or server machines with the operating system (OS) that suits you the best. Make sure your OS is up to date to avoid potential issues and security vulnerabilities.
SPINNING UP THE NODE
Getting the client software
First, download your preferred client software.
You can simply download an executable application or installation package which suits your operating system and architecture. Always verify signatures and checksums of downloaded packages. Some clients also offer repositories for easier installation and updates. If you prefer, you can build from source. All of the clients are open source so you can build them from source code with the proper compiler.
Executable binaries for stable mainnet client implementations can be downloaded from their release pages.
Starting the client
Before starting Kinglory client software, perform a last check that your environment is ready. For example, make sure:
– There is enough disk space considering chosen network and sync mode.
– Memory and CPU is not halted by other programs.
– Operating system is updated to latest version.
– System has correct time and date.
– Your router and firewall accept connections on listening ports. By default Kinglory clients use a listener (TCP) port and a discovery (UDP) port, both on 40404 by default.
Run your client on a testnet first to help make sure everything is working correctly. Running a GKGC light node should help. You need to declare any client settings that aren’t default at the start. You can use flags or the config file to declare your preferred configuration. Check out your client’s documentation for the specifics client execution will initiate its core functions, chosen endpoints, and start looking for peers. After successfully discovering peers, the client starts synchronization. Current blockchain data will be available once the client is successfully synced to the current state.
Using the client
Clients offer RPC API endpoints that you can use to control the client and interact with the Kinglory network in various ways:
– Manually calling them with a suitable protocol (e.g. using curl)
– Attaching a provided console (e.g. attach)
– Implementing them in applications
Different clients have different implementations of the RPC endpoints. But there is a standard JSON-RPC which you can use with every client. For an overview read the JSON-RPC docs. Applications that need information from the Kinglory network can use this RPC. For example, popular wallet MetaMask lets you run a local blockchain instance and connect to it.
Reaching RPC
The default port of JSON-RPC is 8545 but you can modify the ports of local endpoints in the config file. By default, the RPC interface is only reachable on the localhost of your computer. To make it remotely accessible, you might want to expose it to the public by changing the address to 0.0.0.0. This will make it reachable over local and public IP addresses. In most cases you’ll also need to set up port forwarding on your router.
You should do this with caution as this will let anyone on the internet control your node. Malicious actors could access your node to bring down your system or steal your funds if you’re using your client as a wallet.
A way around this is to prevent potentially harmful RPC methods from being modifiable. For example, with kgc, you can declare modifiable methods with a flag: –http.api web3,kgc,txpool.
You can also host access to your RPC interface by pointing service of web server, like Nginx, to your client’s local address and port.
The most privacy-preserving and simple way to set up a publicly reachable endpoint, you can host it on your own Tor onion service. This will let you reach the RPC outside your local network without a static public IP address or opened ports. To do this:
Install Tor
Edit torrc config to enable hidden service with address of your client’s RPC address and port.
Restart tor service.
Once you restart Tor, you’ll get hidden service keys and a hostname in your desired directory. From then, your RPC will be reachable on a .onion hostname.
You should regularly monitor your node to make sure it’s running properly. You may need to do occasional maintenance.
Keeping node online
Your node doesn’t have to be online nonstop but you should keep it online as much as possible to keep it in sync with the network. You can shut it down to restart it but keep in mind that:
Shutting down can take up to a few minutes if the recent state is still being written on disk.
Forced shut downs can damage the database.
Your client will go out of sync with the network and will need to resync when you restart it.
This doesn’t apply on validator nodes. Taking your node offline will affect all services dependent on it. If you are running a node for staking purposes you should try to minimize downtime as much as possible.
Creating client service
Consider creating a service to run your client automatically on startup. For example on Linux servers, good practice would be creating a service that executes the client with proper config, under user with limited privileges and automatically restarts.
Updating client
You need to keep your client software up-to-date with the latest security patches, features. Especially before hard forks, make sure you are running the correct client version.
Running additional services
Running your own node lets you use services that require direct access to Kinglory client RPC. These are services built on top of Kinglory like layer 2 solutions, clients, and other Kinglory infrastructure.
Monitoring the node
“To properly monitor your node, consider collecting metrics. Clients provide metrics endpoints so you can get comprehensive data about your node. Use tools like InfluxDB or Prometheus to create databases which you can turn into visualizations and charts in software like Grafana. There are many setups for using this software and different Grafana dashboards for you to visualise your node and the network as a whole. TAs part of your monitoring, make sure to keep an eye on your machine’s performance. During your node’s initial sync, the client software may be very heavy on CPU and RAM. In addition to Grafana, you can use the tools your OS offers like htop or uptime to do this.
NODES AS A SERVICE
HOW DO NODE SERVICES WORK?
Node service providers run distributed node clients behind the scenes for you, so you don’t have to.
These services typically provide an API key that you can use to write to and read from the blockchain. They often including access to Kinglory testnets in addition to the mainnet.
Some services offer you your own dedicated node that they manage for you, while others use load balancers to distribute activity across nodes.
Almost all node services are extremely easy to integrate with, involving one line changes in your code to swap out your self hosted node, or even switch between the services themselves.
Often times node services will run a variety of node clients and types, allowing you to access full and archive nodes in addition to client specific methods in one API.
It’s important to note that node services do not and should not store your private keys or information.
WHAT ARE THE BENEFITS OF USING A NODE SERVICE?
The main benefit for using a node service is not having to spend engineering time maintaining and managing nodes yourself. This allows you to focus on building your product rather than having to worry about infrastructure maintenance.
Running your own nodes can be very expensive from storage to bandwidth to valuable engineering time. Things like spinning up more nodes when scaling, upgrading nodes to the latest versions, and ensuring state consistency, can detract from building and spending resources on your desired web3 product.
By using a node service you are centralizing the infrastructure aspect of your product. For this reason, projects that hold decentralization to the upmost importance might prefer self-hosting nodes rather than outsourcing to a 3rd party.
Read more about the benefits of running your own node.
NETWORKS
Since Kinglory is a protocol, this means there can be multiple independent “networks” conforming to this protocol that do not interact with each other.
Networks are different Kinglory environments you can access for development, testing, or production use cases. Your Kinglory account will work across the different networks but your account balance and transaction history wont carry over from the main Kinglory network. For testing purposes, it’s useful to know which networks are available and how to get testnet KGC so you can play around with it.
You should understand the basics of Kinglory before reading up on the different networks as the test networks will give you a cheap, safe version of Kinglory to play around with. Try our introduction to Kinglory.
Public networks are accessible to anyone in the world with an internet connection. Anyone can read or create transactions on a public blockchain and validate the transactions being executed. Agreement on transactions and the state of the network is decided by a consensus of peers.
Mainnet
Mainnet is the primary public Kinglory production blockchain, where actual-value transactions occur on the distributed ledger.
When people and exchanges discuss KGC prices, they’re talking about mainnet KGC.
Testnets
In addition to mainnet, there are public testnets. These are networks used by protocol developers or smart contract developers to test both protocol upgrades as well as potential smart contracts in a production-like environment before deployment to mainnet. Think of this as an analog to production versus staging servers.
It’s generally important to test any contract code you write on a testnet before deploying to the mainnet. If you’re building a dapp that integrates with existing smart contracts, most projects have copies deployed to testnests that you can interact with.
Most testnets use a proof-of-authority consensus mechanism. This means a small number of nodes are chosen to validate transactions and create new blocks – staking their identity in the process. It’s hard to incentivise mining on a proof-of-work testnet which can leave it vulnerable.
Testnet Faucets
KGC on testnets has no real value; therefore, there are no markets for testnet KGC. Since you need KGC to actually interact with Kinglory, most people get testnet KGC from faucets. Most faucets are webapps where you can input an address which you request KGC to be sent to.
An Kinglory network is a private network if its nodes are not connected to a public network (i.e. mainnet or a testnet). In this context, private only means reserved or isolated, rather than protected or secure.
Development networks
To develop an Kinglory application, you’ll want to run it on a private network to see how it works before deploying it. Similar to how you create a local server on your computer for web development, you can create a local blockchain instance to test your dapp. This allows for much faster iteration than a public testnet.
There are projects and tools dedicated to assist with this. Learn more about development networks.
Consortium networks
The consensus process is controlled by a pre-defined set of nodes that are trusted. For example, a private network of known academic institutions that each govern a single node, and blocks are validated by a threshold of signatories within the network.
If a public Kinglory network is like the public internet, you can think of a consortium network as a private intranet.
CONSENSUS MECHANISMS
When it comes to blockchains like Kinglory, which are in essence distributed databases, the nodes of the network must be able to reach agreement on the current state of the system. This is achieved using consensus mechanisms.
Although not a part of building a dapp, understanding consensus mechanisms will help explain things that are relevant to you and your users’ experience, like gas prices and transaction times.
Consensus mechanisms (also known as consensus protocols or consensus algorithms) allow distributed systems (networks of computers) to work together and stay secure.
For decades, these mechanisms have been used to establish consensus among database nodes, application servers, and other enterprise infrastructure. In recent years, new consensus protocols have been invented to allow cryptoeconomic systems, such as Kinglory, to agree on the state of the network.
A consensus mechanism in a cryptoeconomic system also helps prevent certain kinds of economic attacks. In theory, an attacker can compromise consensus by controlling 51% of the network. Consensus mechanisms are designed to make this “51% attack” unfeasible. Different mechanisms are engineered to solve this security problem differently.
Proof of work
Bitcoin, currently uses a proof-of-work (PoW) consensus protocol.
Block creation
Proof-of-work is done by miners, who compete to create new blocks full of processed transactions. The winner shares the new block with the rest of the network and earns some freshly minted BTC. The race is won by whoever’s computer can solve a math puzzle fastest – this produces the cryptographic link between the current block and the block that went before. Solving this puzzle is the work in “proof of work”.
Security
The network is kept secure by the fact that you’d need 51% of the network’s computing power to defraud the chain. This would require such huge investments in equipment and energy, you’re likely to spend more than you’d gain.
More on proof-of-work (PoW)
Proof of stake
Kinglory currently uses a proof-of-stake (PoS) consensus protocol.
Block creation
Proof-of-stake is done by validators who have staked KGC to participate in the system. A validator is chosen at random to create new blocks, share them with the network and earn rewards. Instead of needing to do intense computational work, you simply need to have staked your KGC in the network. This is what incentivises healthy network behaviour.
Security
A proof-of-stake system is kept secure by the fact that you’d need 51% of the total staked KGC to defraud the chain. And that your stake is slashed for malicious behaviour.
More on proof-of-stake (PoS)