Skip to content

Instantly share code, notes, and snippets.

View jigar23's full-sized avatar

Jigar jigar23

  • ASAPP Inc
  • Fremont
View GitHub Profile
@jigar23
jigar23 / myfirstcontract.sol
Created May 11, 2018 16:26
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract MyFirstContract {
string private name;
uint private age;
// Can use var newName but that by default will take 256 bits
function setName(string newName) {
name = newName;
}
@jigar23
jigar23 / myfirstcontract.sol
Created May 11, 2018 16:30
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract MyFirstContract {
string private name;
uint private age;
// Can use var newName but that by default will take 256 bits
function setName(string newName) public {
name = newName;
}
@jigar23
jigar23 / myfirstcontract.sol
Created May 15, 2018 16: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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
// Pure Virtual class
interface Regulator {
function checkValue(uint amount) returns (bool);
function loan() returns (bool);
}
// Inheriting Regulator
contract Bank is Regulator {
@jigar23
jigar23 / myfirstcontract.sol
Created May 16, 2018 16: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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
// Pure Virtual class
interface Regulator {
function checkValue(uint amount) returns (bool);
function loan() returns (bool);
}
// Inheriting Regulator
// Anyone can access this bank class, To restrict this
@jigar23
jigar23 / library.sol
Last active May 16, 2018 16:33
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
// using Libraries
library IntExtended {
function Increment(uint self) returns (uint) {
return self + 1;
}
function Decrement(uint _self) returns (uint) {
@jigar23
jigar23 / transaction.sol
Created May 17, 2018 16: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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
// Each contract has an ethereum address can be addressed by
// this
contract Transaction {
// Events can log what is passed to it
event SendLogger(address);
event ValueLogger(uint);
@jigar23
jigar23 / DataTypes.sol
Created June 2, 2018 18:09
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract DataTypes {
bool myBool = false;
// Integers
int8 myInt = -128;
uint8 myUInt = 255;
@jigar23
jigar23 / Ballot.sol
Created June 4, 2018 15:37
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.22;
contract Ballot {
struct Voter {
uint weight;
bool voted;
address delegate;
uint vote;
}
@jigar23
jigar23 / Strings.sol
Created June 4, 2018 16: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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
library Strings {
function concat(string _base, string _value) internal
returns(string)
{
// By default, the type is storage but the value returned by bytes()
// is a memory pointer so explicitely mention that
// In order to modify string, you need to convert it to bytes
// string stores the UTF-8 format which can have > 1 byte
@jigar23
jigar23 / Debugging.sol
Created June 5, 2018 15:55
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.4.23+commit.124ca40d.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Debugging {
uint[] private vars;
function assignment() public pure {
// allocates the memory first before assigning
// so we'll see 2 values in the stack first
// and then the assignment takes place