Skip to content

Instantly share code, notes, and snippets.

@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
// Here's how we would access our contract:
var abi = /* abi generated by the compiler */
var ZombieFactoryContract = web3.eth.contract(abi)
var contractAddress = /* our contract address on Ethereum after deploying */
var ZombieFactory = ZombieFactoryContract.at(contractAddress)
// `ZombieFactory` has access to our contract's public functions and events
// some sort of event listener to take the text input:
$("#ourButton").click(function(e) {
var name = $("#nameInput").val()
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
YourContract.IntegersAdded(function(error, result) {
// do something with result
}
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
pragma solidity ^0.4.19;
contract ZombieFactory {
uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
struct Zombie {
string name;
uint dna;
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
pragma solidity ^0.4.25;
contract ZombieFactory {
uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
struct Zombie {
string name;
uint dna;
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
// create a New Person:
Person satoshi = Person(172, "Satoshi");
// Add that person to the Array:
people.push(satoshi);
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
keccak256(abi.encodePacked("aaaab"));
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
uint[] numbers;
function _addToArray(uint _number) private {
numbers.push(_number);
}
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
pragama ^0.4.25;
contract ZombieFactory{
// test
}
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
pragma solidity ^0.4.25;
contract ZombieFactory {
event NewZombie(uint zombieId, string name, uint dna);
uint dnaDigits = 16;
uint dnaModulus = 10 ** dnaDigits;
struct Zombie {
@panda850819
panda850819 / Markdium-text.txt
Created April 20, 2019 05:07
Markdium-CryptoZombie
uint8 a = 5;
uint b = 6;
// throws an error because a * b returns a uint, not uint8:
uint8 c = a * b;
// we have to typecast b as a uint8 to make it work:
uint8 c = a * uint8(b);