Skip to content

Instantly share code, notes, and snippets.

View madhavanmalolan's full-sized avatar

Madhavan Malolan madhavanmalolan

View GitHub Profile
const subscribe = async () => {
const provider = new Web3Provider(window.ethereum);
const sf = new SuperfluidSdk.Framework({ ethers: provider});
await sf.initialize();
const user = sf.user({
address: await provider.getSigner().getAddress(),
token: '0x6fC99F5591b51583ba15A8C2572408257A1D2797'
});
const flow = await user.flow({
recipient: '0x89Ce0f71D7387a580c6C07032f74f393a65d77F4',
<html>
<head>
<script src="https://cdn.ethers.io/lib/ethers-5.2.umd.min.js"></script>
</head>
<body>
<h1 id="counter">0</h1>
<script>
const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
const signer = provider.getSigner();
@madhavanmalolan
madhavanmalolan / contracts...subquest-8a.sol
Created September 15, 2021 09:52
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract SmartBankAccount {
uint totalContractBalance = 0;
function getContractBalance() public returns(uint){
return totalContractBalance;
}
@madhavanmalolan
madhavanmalolan / contracts...banditloot.sol
Created September 13, 2021 11:27
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
interface Loot {
function ownerOf(uint tokenId) external returns(address);
@madhavanmalolan
madhavanmalolan / contracts...banditloot.sol
Created September 11, 2021 17:21
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
interface Loot {
function ownerOf(uint tokenId) external returns(address);
@madhavanmalolan
madhavanmalolan / contracts...banditloot.sol
Created September 11, 2021 15:15
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.7+commit.e28d00a7.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
interface Loot {
function ownerOf(uint tokenId) external returns(address);
const { ethers } = require("ethers");
const provider = new ethers.providers.InfuraProvider( network = "ropsten" , "Paste infura project id" )
provider.getBlockNumber().then(data => {
console.log("connected to ethereum. current block : " +data);
});
const contractAddress = "paste address";
const contractAbi = [
{
"inputs": [],
@madhavanmalolan
madhavanmalolan / contracts...emit-events-1.sol
Created September 9, 2021 03:10
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.4+commit.c7e474f2.js&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
contract MyErc20 {
string NAME = "MyErc20TokensReallyLongName";
string SYMBOL = "M20";
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
@madhavanmalolan
madhavanmalolan / contracts...subquest-add-compound-1.sol
Created September 7, 2021 09:03
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.4+commit.c7e474f2.js&optimize=false&runs=200&gist=
pragma solidity >=0.7.0 <0.9.0;
interface cETH {
// define functions of COMPOUND we'll be using
function mint() external payable; // to deposit to compound
function redeem(uint redeemTokens) external returns (uint); // to withdraw from compound
pragma solidity >=0.7.0 <0.9.0;
interface cETH {
// define functions of COMPOUND we'll be using
function mint() external payable; // to deposit to compound
function redeem(uint redeemTokens) external returns (uint); // to withdraw from compound