Skip to content

Instantly share code, notes, and snippets.

@jtriley-eth
jtriley-eth / SolidityContract.sol
Last active January 12, 2022 15:16
Simple Solidity Contract Implementation
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Simple read-write contract written in Solidity
/// @author jtriley.eth
/// @notice This is designed to be functionally identical to ./YulContract.sol
/// This is for educational purposes only, do not use in production.
contract SolidityContract {
/// @notice emitted when _myNumber is set
@jtriley-eth
jtriley-eth / YulContract.yul
Last active January 12, 2022 15:22
Simple Yul Contract Implementation
/// @title Simple read-write contract written in Yul
/// @author jtriley.eth
/// @notice This is designed to be functionally identical to ./SolidityContract.sol
/// This is for educational purposes only, do not use in production.
object "YulContract" {
code {
/// @dev Deploys the contract
datacopy(0, dataoffset("runtime"), datasize("runtime"))
return (0, datasize("runtime"))
}
@jtriley-eth
jtriley-eth / idaBatch.ts
Last active January 19, 2022 23:49
IDAv1 Batch Call
import { Framework } from '@superfluid-finance/sdk-core'
import { ethers } from 'ethers'
// extracted from `./.env`
const apiKey = process.env.API_KEY
const privateKey = process.env.PRIV_KEY
// intializing
const provider = new ethers.providers.InfuraProvider('matic', apiKey)
const sf = await Framework.create({ networkName: 'matic', provider })
@jtriley-eth
jtriley-eth / MetaStreamCloser.draft.md
Created January 25, 2022 17:21
Closing Flows on a User's Behalf with Meta Transactions

MetaStreamCloser

Abstract

The MetaStreamCloser contract allows a user to provide a digital signature, giving permission to a third party to close streams on the user's behalf. A stream's sender or receiver may propmt the contract for a message to sign, the message being a deleteFlow function call. By generating a signature and sending it to a third party, that third party has access to explicitly delete the unique flow of a token between the sender and receiver exactly once.

@jtriley-eth
jtriley-eth / ERC20ForwardRequest.sol
Created January 26, 2022 17:38
ERC20 Forward Request Struct
interface IForwarder {
/// @dev Full ERC20 Forward Request, Not all fields are relevant
/// @param from Account that signs the metatransaction (sender)
/// @param to Target address to execute function call (Superfluid host)
/// @param token Token to collect meta-tx fees in (not applicable)
/// @param txGas Gas provided for call execution
/// @param tokenGasPrice Token amount for meta-tx fee (not applicable)
/// @param batchId Unique ID of meta-tx batch
/// @param batchNonce Nonce unique to `from` and `batchId`
/// @param deadliine Execution deadline timestamp (zero for no deadline)
@jtriley-eth
jtriley-eth / Signatures.md
Last active January 26, 2022 20:25
Biconomy Function Signatures

Biconomy Function Signatures

// ---------------------------------- //
// signature
"getNonce(address,uint256)"

// keccak256 hash
0x895358038f2a11adf6dc83f52acf8e031067227760d4efa3d9a55399e3a98616
@jtriley-eth
jtriley-eth / IForwarder.sol
Created January 26, 2022 20:43
Biconomy Forwarder Interface
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Interface extracted from Biconomy Source Code.
/// @author jtriley.eth
/// @notice This allows us to interface with the Trusted Forwarder contract that
/// will call the respective functions on the Superfluid host.
interface IForwarder {
/// @dev Full ERC20 Forward Request, Not all fields are relevant
@jtriley-eth
jtriley-eth / TheSentinel.draft.md
Created February 12, 2022 14:02
General Purpose Sentinel Draft

The Sentinel

Abstract

There is an increasing need for off-chain infrastructure in the Supefluid ecosystem as more projects, protocols, and individuals need to interact with contracts in complex, scheduled, or automated ways. This includes, but is not limited to, insolvent stream liquidation, pre-insolvency courtesy stream closures, scheduled transactions, and meta transactions.

@jtriley-eth
jtriley-eth / signaures.csv
Last active October 7, 2022 17:54
Superfluid-Related Function Signatures
selecetor contract_name signature_type signature
0x0023de29 ERC777RecipientDrainingGas function tokensReceived(address,address,address,uint256,bytes,bytes)
0x0023de29 ERC777RecipientReverting function tokensReceived(address,address,address,uint256,bytes,bytes)
0x0023de29 IERC777Recipient function tokensReceived(address,address,address,uint256,bytes,bytes)
0x0023de29 TOGA function tokensReceived(address,address,address,uint256,bytes,bytes)
0x00fdd58e ERC1155 function balanceOf(address,uint256)
0x00fdd58e ERC1155Burnable function balanceOf(address,uint256)
0x00fdd58e ERC1155Pausable function balanceOf(address,uint256)
0x00fdd58e ERC1155PresetMinterPauser function balanceOf(address,uint256)
0x00fdd58e ERC1155Supply function balanceOf(address,uint256)
@jtriley-eth
jtriley-eth / Snippet.sol
Created February 16, 2022 12:59
Agreement Snippet
// --snip--
_host.callAgreement(
_cfa,
abi.encodeWithSelector(
_cfa.createFlow.selector,
token,
receiver,
flowRate,
new bytes(0)