This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YourContract.IntegersAdded(function(error, result) { | |
// do something with result | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.19; | |
contract ZombieFactory { | |
uint dnaDigits = 16; | |
uint dnaModulus = 10 ** dnaDigits; | |
struct Zombie { | |
string name; | |
uint dna; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.25; | |
contract ZombieFactory { | |
uint dnaDigits = 16; | |
uint dnaModulus = 10 ** dnaDigits; | |
struct Zombie { | |
string name; | |
uint dna; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a New Person: | |
Person satoshi = Person(172, "Satoshi"); | |
// Add that person to the Array: | |
people.push(satoshi); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keccak256(abi.encodePacked("aaaab")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint[] numbers; | |
function _addToArray(uint _number) private { | |
numbers.push(_number); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragama ^0.4.25; | |
contract ZombieFactory{ | |
// test | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.25; | |
contract ZombieFactory { | |
event NewZombie(uint zombieId, string name, uint dna); | |
uint dnaDigits = 16; | |
uint dnaModulus = 10 ** dnaDigits; | |
struct Zombie { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
NewerOlder