Foraying into Blockchain

Derry Birkett
Jun 3, 2018 · 2 min read

Blockchain is a zany cool idea, especially for crypto-anarchists like me. I’ve been wading deeper into crypto this weekend; got myself setup with Metamask, started hunting Bounties, opened my Gitcoin tip jar, joined some slack & telegram communities and became a Level 1 Crypto-Zombie.

Remember one of my recent posts about giving up coding? yeah, forget that. I’m full of sh*t. Here I go again, this time raking at the blockchain soil.

So, here is my crypto-zombie Ethereum Solidity Contract (s’no’biggie — just a Zombie generating blockchain hook).

pragma solidity ^0.4.19;contract ZombieFactory {event NewZombie(uint zombieId, string name, uint dna);uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
struct Zombie {
string name;
uint dna;
}
Zombie[] public zombies;function _createZombie(string _name, uint _dna) private {
uint id = zombies.push(Zombie(_name, _dna)) — 1;
NewZombie(id, _name, _dna);
}
function _generateRandomDna(string _str) private view returns (uint) {
uint rand = uint(keccak256(_str));
return rand % dnaModulus;
}
function createRandomZombie(string _name) public {
uint randDna = _generateRandomDna(_name);
_createZombie(_name, randDna);
}
}

It really is no biggie because I took the tutorial here ( you do need some basic JS fu to get through it without cheating ).

The awesome thing about being a level 1 crypto-zombie is a better understanding of how blockchain works. Even though the above is a tutorial, I was still stoked to learn how to write some data to a blockchain! You can also share functions and events with the entire eco-system, which is a pretty mind-blowing concept if you pause to think (*checks phone).

Onwards to Buidling Blockstack dApps!

Image for post
Image for post

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store