XAYA in a nutshell - RenegadeMinds/testbed GitHub Wiki
XAYA is a platform that enables true blockchain gaming. Fully decentralised autonomous universes running without servers and virtually unstoppable.
For minimal fees, people can create unique names and update them with a value. These are stored on the XAYA blockchain where anyone can see them. Only the person who created a name has its private key and can update it.
For example, Alice created her name "p/ALICE". It cost a total of 0.010413 CHI. 0.01 CHI is stored in Alice's new name, and 0.000413 CHI covers the transaction fee. Now, she can update her name with any value she pleases.
These name values can be used for moves or orders or items or virtually anything in games.
Alice and Bob both have their own names, "p/ALICE" and "p/BOB" and they decide to play chess on the XAYA blockchain. Alice is white and begins with king's pawn e2 to e4. Her move on the blockchain are as shown below. (We'll explain everything later, and you'll even issue your own orders into a live, functioning, minimalist game!)
{"g":{"chess":{"m":"e2-e4"}}}
Bob makes the same opening move of king's pawn e7 to e5. His move on the blockchain looks like this:
{"g":{"chess":{"m":"e2-e4"}}}
Now anyone in the world can see their moves and follow their game.
Indeed, someone is following it: the chess game application, i.e. the program they are using to play chess. We'll call it ChessX.
Inside of ChessX it watches each of Alice and Bob's moves on the blockchain. When a new move comes in, it processes the move, e.g. for error checking, checkmate, etc., and then updates the front end (GUI).
Because Alice is the only person with the private keys for "p/ALICE", and Bob is the only person with the private keys for "p/BOB", the game is secure, and we know that Alice and Bob truly made the moves we see in their names' values. Cheating and fraud are impossible in XAYA games. Sorry Chuck, but you can't cheat Alice or Bob!
There are 3 main components to a XAYA application or game.
- XAYA daemon
- Game state processor
- Front end
The daemon (xayad) is responsible for the blockchain portion of a XAYA game. It processes transactions, such as when Alice sends a ChessX move. xayad also provides the entire blockchain database so that everyone can see what happened with perfect transparency.
The Game State Processor (GSP) is where the game happens. Moves are processed, and new game states are created.
The front end is where the game is displayed for players. This is what players interact with. All the blockchain goodness is invisible to them.
Are you ready to get started? Let's dive in!
XAYA wallets contain xayad. They're a convenient front end to xayad, just as how XAYA game GUIs are front ends for the GSP.
If you haven't already, download a XAYA wallet here then extract the ZIP file.
Open a command prompt or terminal and navigate to the wallet folder.
Run the following command:
xayad -rpcport=8396 -rpcuser=user -rpcpassword=password
The blockchain will begin synchronising (downloading) the blockchain. This can take some time and largely depends on your computer and network connection.
Open up another command prompt or terminal and navigate again to the xayad folder. You'll use this window to issue commands.
Now that we have the daemon running, we'll use the XAYA Command Line Interface (xaya-cli) or curl to issue commands. It's very easy and you'll learn along the way. For XAYA, you'll find that xaya-cli is far easier than curl.
Your first task is to check the network. Here are the xaya-cli and curl commands:
xaya-cli getnetworkinfo
curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnetworkinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8396/
NOTE: With both xaya-cli and curl you will need to ensure that you've properly escaped anything that requires it.
Those commands will return something similar to this:
{
"version": 1019900,
"subversion": "/Xaya:1.1.99/",
"protocolversion": 110015,
"localservices": "000000000000040d",
"localrelay": true,
"timeoffset": 1,
"networkactive": true,
"connections": 8,
"networks": [
{
"name": "ipv4",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "ipv6",
"limited": false,
"reachable": true,
"proxy": "",
"proxy_randomize_credentials": false
},
{
"name": "onion",
"limited": true,
"reachable": false,
"proxy": "",
"proxy_randomize_credentials": false
}
],
"relayfee": 0.00100000,
"incrementalfee": 0.00001000,
"localaddresses": [
],
}
From here we can see that we are connected to 8 nodes. Which is the set maximum number of outgoing connections in the client. It's possible to open ports on your system to receive incoming connections, but this is not required. You can ignore the information in there at this stage.
If you don't have any connections then you may need to wait a few minutes or you may have some networking issues on your computer, so you should sort that out before continuing.
Next, lets check how far we are with syncing. Type in one of the following commands.
xaya-cli getblockchaininfo
curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8396/
You'll get a result similar to this:
{
"chain": "main",
"blocks": 598466,
"headers": 598466,
"bestblockhash": "4ff74462ecde7624ed069687954da31cec2c3fc3328a669b7a62511a5ad7753d",
"mediantime": 1550319823,
"verificationprogress": 0.9999955845690718,
"initialblockdownload": false,
"chainwork": "0000000000000000000000000000000000000000001a29ea874e394c2041f282",
"size_on_disk": 567360856,
"pruned": false,
"softforks": [
{
"id": "bip34",
"version": 2,
"reject": {
"status": true
}
},
{
"id": "bip66",
"version": 3,
"reject": {
"status": true
}
},
{
"id": "bip65",
"version": 4,
"reject": {
"status": true
}
}
],
"bip9_softforks": {
},
}
The value for blocks
is the current block your client is synced with. The headers
value is the current block number of the headers downloaded. Generally if you are still syncing, headers is greater than blocks. Once you are fully synced, blocks = headers.
You can check if you are fully synced by checking the block explorer, which should be on the latest block.
On Linux you can use the following command to see the blocks come in in real time.
watch xaya-cli getblockchaininfo
Our examples use mainnet which requires real CHI. For these tutorials, you'll need less than 0.1 CHI. Developers can ask for that CHI in our Forums, Telegram, or other channels. You need only provide a valid CHI address.
However, you can also do this on testnet or regtestnet for free. See here for more information about that.
If you wish to purchase CHI (i.e. real CHI on mainnet), see our website for where you can do that.
Names are the core of XAYA. Only YOU can control your name and do moves in games. Creating names is very easy.
In your command prompt, issue a command like this where "<my name>" is your chosen name:
xaya-cli name_register "p/<my name>" "{}"
curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "name_register", "params": [{\"p/<my name>\"}] }' -H 'content-type: text/plain;' http://127.0.0.1:8396/
You should receive a response as a transaction ID, which is a long hexadecimal value, e.g.:
RESPONSE IN HEX
If it fails, most likely you've tried to get a name that is already reserved. Check the error message and try again.
Congratulations! You've immortalised yourself on the XAYA blockchain!
Now that you have a name, it's time to say hello!
Try running the following command with the name you registered above.
xaya-cli name_upgade "p/<my name>" "{\"g\":{\"helloworld\":{\"m\":\"Hello everybody!\"}}}"
Note how the value is escaped with back slashes.
Now we can look at what you did above. Try running the following command with your name.
xaya-cli name_show "p/<my name>"
Run that and you should see some information about your name along with the value you set for it.
Congratulations! You're well on your way to being a XAYA maven!