Skip to content

Instantly share code, notes, and snippets.

View anubhavgirdhar's full-sized avatar

Anubhav Girdhar anubhavgirdhar

View GitHub Profile
@anubhavgirdhar
anubhavgirdhar / Bunch.sol
Created August 17, 2020 14:20
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.6.12+commit.27d51765.js&optimize=false&gist=
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import "./BunchStorage.sol";
contract Bunch is BunchStorage {
/**
@anubhavgirdhar
anubhavgirdhar / 1_Storage.sol
Created August 6, 2020 13: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.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity >=0.4.22 <0.7.0;
/**
* @title Storage
* @dev Store & retreive value in a variable
*/
contract Storage {
uint256 number;
@anubhavgirdhar
anubhavgirdhar / EIP712.sol
Created August 5, 2020 16:57
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.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity ^0.5.0;
contract EIP712 {
mapping(address => uint256) public nonces;
struct EIP712Domain {
string name;
string version;
uint256 chainId;
@anubhavgirdhar
anubhavgirdhar / EIP712.sol
Created August 3, 2020 01: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.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity ^0.5.0;
contract EIP712 {
mapping(address => uint256) public nonces;
struct EIP712Domain {
string name;
string version;
uint256 chainId;
@anubhavgirdhar
anubhavgirdhar / EIP712.sol
Created July 24, 2020 01: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.5.17+commit.d19bba13.js&optimize=true&gist=
pragma solidity ^0.5.0;
contract EIP712 {
mapping(address => uint256) public nonces;
struct EIP712Domain {
string name;
string version;
uint256 chainId;
@anubhavgirdhar
anubhavgirdhar / EIP712.sol
Created July 22, 2020 12:36
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.6.6+commit.6c089d02.js&optimize=false&gist=
pragma solidity ^0.5.0;
contract EIP712 {
mapping(address => uint256) public nonces;
struct EIP712Domain {
string name;
string version;
uint256 chainId;
@anubhavgirdhar
anubhavgirdhar / EIP20Interface.sol
Created June 5, 2020 22:19
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.6.6+commit.6c089d02.js&optimize=false&gist=
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
pragma solidity ^0.4.21;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
@anubhavgirdhar
anubhavgirdhar / EIP20Interface.sol
Created May 30, 2020 20:18
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.17+commit.d19bba13.js&optimize=false&gist=
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
pragma solidity ^0.4.21;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
@anubhavgirdhar
anubhavgirdhar / App.js
Created May 13, 2020 15:58
Front End for a DApp to deposit Ether into Compound Finance
const contractAddress = "0x722870Eca028c681994c4d82DA3b82f1263Ca07e";
const contractAbi = [{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]
const myContract = new web3.eth.Contract(contractAbi, contractAddress);
(function deposit(){
await myContract.methods.deposit.send({from : userAddress,value :1000000000000000000})})();
@anubhavgirdhar
anubhavgirdhar / zap.sol
Last active May 14, 2020 16:44
Smart Contract for depositing Eth into Compound
pragma solidity ^0.5.0;
interface CtokenInterface {
function mint() external payable;
function transfer(address, uint256) external returns (bool);
function balanceOf(address owner) external view returns (uint256);
}
contract Zap{
address cEthAddress = 0xf92FbE0D3C0dcDAE407923b2Ac17eC223b1084E4;