Skip to content

Instantly share code, notes, and snippets.

View vis-kid's full-sized avatar

ed wassermann vis-kid

  • Milky Way
View GitHub Profile
@vis-kid
vis-kid / contracts...18_Struct.sol
Created February 5, 2022 23:45
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.12+commit.7709ece9.js&optimize=false&runs=200&gist=
pragma solidity 0.5.12;
contract Struct {
struct Todo {
string text;
bool completed;
}
Todo[] public todos;
@vis-kid
vis-kid / contracts...17_Enum.sol
Created February 5, 2022 23:14
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract Enum {
enum Status {
Pending,
Shipped,
Accepted,
Rejected,
Canceled
}
@vis-kid
vis-kid / contracts...16_Person.sol
Created February 5, 2022 23:06
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.11+commit.d7f03943.js&optimize=false&runs=200&gist=
pragma solidity 0.8.11;
contract Persons {
uint public peopleCounter;
struct Person {
string firstName;
string lastName;
address PersonAddress;
@vis-kid
vis-kid / contracts...contracts 01...15_Mappings.sol
Created February 4, 2022 20:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract Mapping {
mapping(address => uint) public myMap;
function setMapping(address _address, uint _number) external {
myMap[_address] = _number;
}
function getMapping(address _address) external view returns (uint) {
@vis-kid
vis-kid / contracts...contracts 01...14_Loops.sol
Created February 4, 2022 20:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract Loop {
uint public counter;
function loop(uint number) public {
for (uint i = 0; i < number; i ++) {
counter += 1;
}
}
}
@vis-kid
vis-kid / contracts...contracts 01...13_Errors.sol
Created February 4, 2022 20:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract Errors {
uint public balance;
uint public constant MAXAMOUNT = 2 ** 256 -1;
function deposit(uint _amount) external {
uint oldBalance = balance;
uint newBalance = balance + _amount;
require(newBalance >= balance, "Error");
@vis-kid
vis-kid / contracts...12_InheritanceConstructors.sol
Created February 4, 2022 20:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract A {
string public name;
constructor(string memory _name) public {
name = _name;
}
}
@vis-kid
vis-kid / contracts...11_Inheritance2.sol
Created February 4, 2022 20:07
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.5.11;
contract A {
event Log(string message);
function foo() public {
emit Log("Contract A.foo was called");
}
@vis-kid
vis-kid / contracts...10_Inheritance.sol
Created February 4, 2022 20:07
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.8.11;
contract A {
string public name;
constructor(string memory _name) {
name = _name;
}
}
@vis-kid
vis-kid / contracts...9_Constructor.sol
Created February 4, 2022 20:07
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.5.11+commit.22be8592.js&optimize=false&runs=200&gist=
pragma solidity 0.8.11;
contract Constructor {
uint public a;
string public b;
address public owner;
uint public createdAt;
constructor(uint _a, string memory _b) {
a = _a;