
Learn to Code Ethereum DApps by Building Your Own Game - alanfalcon
https://cryptozombies.io/
======
tomasien
There's a lot of hate on here for blockchain gaming/rare digital art so I'd
like to clarify two points.

1\. Blockchain games are best when only the necessary work is done on chain,
such as transfer of ownership or enforcement of critical rules at run time.
This tutorial may not show that so as to demonstrate the power of the
blockchain, but most people in the space are building only the components
players want to not be controlled by a central entity into the blockchain. It
works fine.

2\. The lack of digital scarcity is a real problem for artists. Blockchain art
is a real solution. Artists I talk to are extremely excited about the ability
to issue limited/special editions of their art on the blockchain that can
owned and traded by their biggest fans. It's not about hiding the source art
(image, music, etc) from the public, it's about having "signed" and
"authentic" editions folks can collect and trade. They've lost that ability in
the digital art world and this gives it back to them.

~~~
jmduffy
One of the CryptoZombies creators here. This comment is spot-on.

In the realm of gaming, digital ownership of in-game assets is one area we're
really excited about. Economies have already sprung up in many online games
around selling items for real-world cash. With something like ERC721 tokens on
Ethereum, you would truly own your items outside of the company's web server.
No one could take them away from you, the items could be provably scarce, and
you would have full control over selling or trading them on decentralized
marketplaces (in a secure way).

Or take collectible card games like Magic the Gathering — these types of games
are an ideal fit for the blockchain for the same reasons as above — rare,
collectible, and tradable assets with a real-world value.

You could even have multiple games or apps that read the same crypto assets.
This means you could build a new game, but use the assets of an existing game
with a large user-base. You would be able to tap into a large community of
players who could instantly jump into your game world with their existing
characters. This lends itself to some really interesting new possibilities —
imagine a World of Warcraft type game, where players were playing in the towns
and worlds created by players of a totally different MineCraft or Sim-City-
like game. Two sets of players playing entirely different games, but they
could be playing in the same game-world where their actions have real effects
on the other game through decentralized shared data.

As you mentioned, there are currently serious limitations for how much can be
done on-chain. Our solution to this scalability problem is have DApps run on
their own sidechains. So the in-game tradable assets would be hosted on
Ethereum, while the heavy game logic and the rest of the client would live on
a sidechain. This way the entire game would be running on a blockchain instead
of only a small part on chain and the rest on a centralized server.

One of the huge benefits of a game running on its own blockchain is
forkability. There have been plenty of examples in games where the developers
released a change that nerfs a favorite character or spell, or the creators
shut down the server entirely and stop supporting it.

If the game were running on its own blockchain, the users running nodes could
reject the software update and hard fork. They could continue running on a
legacy version of the client indefinitely, so long as there were still nodes
running it. Basically the entirety of the game data is stored on the
sidechain, so both sets of nodes could go their separate ways and play the
version of the game they prefer. And no one could shut down the game server as
long as there were nodes willing to support it.

For those who are interested in more info, here's an article that outlines
some of the motivations behind sidechain-based games and community sites and
what we're building: [https://medium.com/loom-network/million-user-dapps-on-
ethere...](https://medium.com/loom-network/million-user-dapps-on-ethereum-an-
introduction-to-application-specific-sidechains-c0fdc288c5e5)

CryptoZombies is just intended as an intro to building apps on Ethereum to get
more developers in the space. Up until now the focus on blockchains has been
on financial apps, but we think the potential is much bigger than that. We're
betting on games being one of the first areas to bring blockchain tech to the
mainstream, and we hope CryptoZombies inspires developers to get onboard!

~~~
Cyberdog
> No one could take them away from you

The DAO fork.

Sorry, but the Etherium team/chain/community has no credit when it comes to
irreversibility.

~~~
t3chn0SchO0lbus
The hackers still have their assets as Ethereum Classic. The fact that ETC
lives on is a testament to how nobody could 'take away' what is listed as
theirs on the blockchain.

But I don't buy this argument for video games. Most of the game code ought to
live outside of the blockchain and that non-blockchain code/art would be
difficult to reproduce let alone subject to copyright claims or closed source.

Another random video game thought: Would item storage on blockchain mean that
every player could see the inventory of every other player?

~~~
alanfalcon
The "no secrets on the blockchain" aspect has already played out in subtly
interesting ways in Cryptokitties. I have a tool that lets me see in a moment
whether a given account has gained or lost money, and how much, and how much
they were willing to spend. The marketplace is a completely open book, with
real time sales data and a full history. You can't breed kitties in secret in
pursuit of a particular breed. You can't (easily) buy out all of a given trait
on the marketplace to create a false sense of high demand. And yes, you can
see the entire kitty inventory of any other CK player.

~~~
AdamSC1
That's based on one current implementation of a gaming DApp.

It's worth noting that you can achieve semi-privacy through either on-
chain/off-chain hybrids, as well as some other emerging efforts.

One example I've been playing around with is to use the multi-address
approach:

In your database each "player" consists of multiple addresses each which are
OR-multi-sig wallets, for various inventory elements and stats.

When they log in via a system like metamask, their main wallet (PlayerID) is
unlocking an account which in your games database (off-chain) ties together
another set of "master wallets" together with you've given the player private
keys for - for each item, or each set of X items, in the players inventory you
are setting up a new smart contract that is a OR-multi-sig wallet.

For this wallet, which holds the item, there are two possible signatories the
first being the game's main contract, so that the game can add/remove items
from players based on game events, and then one of the players private keys.

While you'd likely need a custom fork of metamask to handle the multi-key
environment, you've made a system where:

* Player's inventory cannot be know from one private address.

* Player's retain full control over the items.

* Player's have private key access to the items in case the service goes down.

* You store player data off-chain, but in a way that your service is not crucial to the game.

* Player assets can be traded off-game without updating the game service.

* Data about individual items is still public, and does not need to be obscured, oraclized or stored off chain.

The current blocker isn't any specific blockchain technology, but just having
a good multi-key management UI for users.

~~~
alanfalcon
Brilliant. Definitely interested to see how this space evolves! Metamask is a
great first step to helping bring wallets to the masses in the web browser,
and it continues to improve, but it certainly isn't what a mainstream web
wallet extension will look like in a couple years.

------
runeks
In all seriousness, who would want to build a game on top of a platform that’s
currently limited to ~15 state changes per second? And where each of these
state changes cost money?

I get the interesting aspect of creating a game with a limited supply of some
virtual good, but how much energy does it make sense to put into a game of
this nature when the underlying platform prevents your game from becoming
successful (because it can’t handle that kind of load)?

I suspect there’s a genuine use case for limiting the supply of virtual goods
in games, but I doubt the solution involves all games performing state updates
using on-chain transactions in a single, shared blockchain.

~~~
disko
Better to do this on NEO instead. Their tech is better than ETH in every way;
it can handle up to 10.000 transactions per second (whereas ETH can handle
~15) and it supports almost all mainstream coding languages. What's more,
transactions are free.

~~~
tstyle
Is there a downside or trade off? I’m a little skeptical that NEO is strictly
better in all aspects.

~~~
Cybourgeoisie
Cryptokitties is possible because of ERC 721, which allows for unique tokens
to represent individual assets (having an indivisible kitty with its own dna).
As far as I'm aware, NEO doesn't yet provide the ability to create
individualized tokens that can be stored on the blockchain in a similar way.

~~~
zeroxfe
ERC 721 just an API standard for non-fungible assets. There's nothing special
on inherent to Ethereum that makes Cryptokitties possible.

You can totally build something Cryptokitties with NEO -- the only difference
is that because there isn't a standard, there isn't a third-party marketplace
for these assets. (i.e., there's nothing inherent about NEO that prevents
something like Cryptokitties from being built.)

------
arkad
I had birthday yesterday. , Statistically by the life expectancy in my
country, I'm now closer to death than to the date of birth. And yet, what
makes me feel old is the idea of writing games on top of ethereum.

~~~
hmate9
Hahahaha this has to be the greatest comment ever

~~~
shobith
Really?

------
alanfalcon
I'm little afraid of all the CryptoKitties clonies that this will cause to
come into existence, but it's pretty easy to spot the low effort cash grab
ponzies and to see that CryptoKitties itself has a ton of thought and effort
(and talent/money) behind it [I'm obsessed, feel free to ask me all your CK
questions, like "why did you use all your Ether buying pictures of cats
instead of a used car?].

Anyway, this is incredible.

~~~
geraldbauer
Big fan of CryptoKitties too. Adding my notes to the Awesome CryptoKitties
(and CryptoCopycats) [1] page @ Open Blockchains. PS: Launching CryptoCopycats
soon - lets you play for free (without gas or ether) an (open source)
CryptoKitties unchained version, that runs off the blockchain :-) still using
a hyper ledger and a peer-to-peer network (but built from scratch) though. [1]
[https://github.com/openblockchains/awesome-
cryptokitties](https://github.com/openblockchains/awesome-cryptokitties)

~~~
julius
What is a "hyper ledger"? (google tells me it is a linux foundation
project...)

~~~
nsomaru
Corporates who missed the blockchain boat building their own boats.

------
xerophyte12932
I have almost no idea about the Ethereum system, but don't you have to pay to
have your code executed on the global ethereum machine? Does that mean I have
to pay to test run my code? or maybe after I deploy it?

~~~
edf13
You can run your code on a test network:

[http://ethdocs.org/en/latest/network/test-
networks.html](http://ethdocs.org/en/latest/network/test-networks.html)

------
DougN7
IMHO, this reflects all that is bad about blockchains. So many systems around
the world having to forever track nonsense like who owns a fake kitty. This is
bloat.

Throw it in a database that is owned by a virtual-kitty-selling company. Yeah,
it's not decentralized. So what? It's a game! IMO the blockchain should be for
important (financial/legal/real estate/?) transactions.

~~~
zilian
"I don't like it so it shouldn't exist" ! I think this tutorial is very cool,
I introduced programming and dapps to my 15 yo niece with it and she liked it.

~~~
DougN7
It doesn't matter that I don't like it. Every addition to the blockchain
imposes costs in storage, backup and transmission - forever. Nothing gets
removed, so it just keeps growing. For property records that's a cost worth
bearing (we had to record who owned what anyway). But how long and how much
will it cost to forever record that Bob owned Kitty XYZ and then sold it to
Allen? Multiply that by 50,000 other apps, and (millions?) of frivolous
transactions. Just because we can doesn't mean we should.

~~~
t3chn0SchO0lbus
It doesn't have to be like that. We could rely on periodic snapshots of the
blockchain for future validation. We could even selectively include specific
data in the snapshots to be preserved. Maybe some group might need to store
the entire history of the blockchain but there is a lot of room for innovation
to solve this scaling dilemma.

------
indescions_2018
With the usual caveats about putting real money into risky speculative assets.
Blockchain technology could very well prove to be the missing link in
providing a way to cryptographically "sign" a digital art work. And publicly
verify its uniqueness and provenance.

If you wish to experience the hype first hand. There's a show, perhaps the
first of its kind, happening in NYC this weekend. With the founders of
CryptoKitties, RarePepes, DADA, Cryptopunks, Decentraland in attendance.

Rare Digital Art Festival, Rise New York, 43 West 23rd St, NYC, Sat Jan 13,
9am

[https://raredigitalartfestival.splashthat.com/](https://raredigitalartfestival.splashthat.com/)

~~~
tomasien
Wow thanks for sharing the event! It's going to be something else, I can't
believe how excited folks are for rare digital art. The movement does feel
like something special not just in the blockchain world but in the tech world
in particular.

------
crack-the-code
I can't imagine how immensely powerful it would be to have a game like Diablo
leverage block chain for its items. This would eliminate the risk of dupes and
ensure a fair system.

~~~
dangero
The risk of dupes meaning that the company that created the game may release
duplicate items? A centralized database can eliminate that risk as well.

------
thisisit
I wonder if there are any tutorials for building ERC-20 or 71 tokens?

And also is there a tutorial on how to download the whole ethreum blockchain
and parse it to a databse for analysis purposes?

~~~
viach
Here is the tutorial:
[https://www.ethereum.org/token](https://www.ethereum.org/token)

There is the BitcoinTalk forum for announcing your new super token
[https://bitcointalk.org/index.php?board=159.0](https://bitcointalk.org/index.php?board=159.0)

Voila!

------
gcb0
anyone found the tutorial (or a similarly recommend one) in text?

------
decorator
(Disclaimer: I hold some Enigma).

I'm (self)-interested in learning about Enigma[0]. It's an off-chain solution
for scalability & privacy with regards to systems of blockchains (blockchain
agnostic).

It also has the capacity for its own dapps. The Enigma product isn't
completed, yet there is a working product on top of the protocol called
Catalyst[1] (I've not personally tried Catalyst, yet). Catalyst is a trading
app for quants.

Enigma is supported by MIT, & has Alex Pentland as an advisor.

There's more to Enigma than what I've just outlined. 1) There's the data
marketplace component. 2) It could also conceivably become a secure data
processing layer for the Internet. I think it can be used with different
protocols. I've yet to figure that out.

[0] [https://www.enigma.co](https://www.enigma.co) [1]
[https://enigmampc.github.io/catalyst/](https://enigmampc.github.io/catalyst/)

