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 / Arrays.sol
Created June 26, 2018 16:24
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.23;
/**
* @dev Extended library for address array
*/
library AddressArrayExtended {
/**
* @dev Removes the address *value* from the list of _self[]
* @notice Returns false if value is not found
@jigar23
jigar23 / Arrays.sol
Created June 26, 2018 15: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.23;
// Make this a library
contract AdrressArray {
address[] private m_array;
constructor(address[] array) public payable
{
m_array = array;
@jigar23
jigar23 / MultipleReturnValues.sol
Created June 23, 2018 19:43
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.10;
contract MultipleReturn {
function returnFirstValue(uint a, uint b) public pure returns (uint) {
return a;
}
function caller() public pure returns (uint) {
return returnFirstValue({a: 5, b: 10});
}
@jigar23
jigar23 / MultipleReturnValues.sol
Created June 22, 2018 15:24
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.10;
contract MultipleReturn {
function returnFirstValue(uint a, uint b) public pure returns (uint) {
return a;
}
function caller() public pure returns (uint) {
return returnFirstValue({a: 5, b: 10});
}
@jigar23
jigar23 / Polymorphism.sol
Created June 21, 2018 15:04
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;
interface Letter {
function n() external returns (uint);
}
contract A is Letter {
function n() public returns (uint) {
return 1;
@jigar23
jigar23 / Polymorphism.sol
Created June 19, 2018 15:42
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;
interface Letter {
function n() external returns (uint);
}
contract A is Letter {
function n() public returns (uint) {
return 1;
@jigar23
jigar23 / TimeBased.sol
Created June 19, 2018 15: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.23;
contract TimeBasedWill {
address private _beneficiaries;
uint private _startTime;
uint private _expiryTime;
address private owner;
@jigar23
jigar23 / EtherTransfer.sol
Created June 19, 2018 15: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;
contract EtherTransferTo {
// fallback function no argument no return value
function() public payable {
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
@jigar23
jigar23 / EtherTransfer.sol
Created June 13, 2018 15:48
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 EtherTransferTo {
// fallback function no argument no return value
function() public payable {
}
function getBalance() public view returns (uint) {
return address(this).balance;
}
@jigar23
jigar23 / ERC20.sol
Created June 12, 2018 15:29
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;
interface ERC20 {
function transferFrom(address _from, address _to, uint _value) public returns (bool);
function approve(address _spender, uint _value) public returns (bool);
function allowance(address _owner, address _spender) public constant returns (uint);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}