Skip to content

Instantly share code, notes, and snippets.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;
// returns 42
function freePure() pure returns (uint8) {
return 42;
}
// takes a function and returns that same function
function freeHigherOrder(

Sway Language

Rust-like lang.

Install

cargo install forc fuel-core
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
// Used in the `name()` function
// "Yul Token"
bytes32 constant nameLength = 0x0000000000000000000000000000000000000000000000000000000000000009;
bytes32 constant nameData = 0x59756c20546f6b656e0000000000000000000000000000000000000000000000;
// Used in the `symbol()` function
// "YUL"
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
// Used in the `name()` function
bytes32 constant nameLength = 0x0000000000000000000000000000000000000000000000000000000000000009;
bytes32 constant nameData = 0x59756c20546f6b656e0000000000000000000000000000000000000000000000;
// Used in the `symbol()` function
bytes32 constant symbolLength = 0x0000000000000000000000000000000000000000000000000000000000000003;
bytes32 constant symbolData = 0x59554c0000000000000000000000000000000000000000000000000000000000;
// import `thread` module from std lib and `mpsc` module from `sync` from std lib
use std::thread;
use std::sync::mpsc;
// program entry point
fn main() {
// create sender and receiver with `channel()`
let (sender, receiver) = mpsc::channel();
// import `thread` module from the standard library
use std::thread;
// entry point of the program
fn main() {
// spawn a new thread with the `spawn` method in the `thread` module
thread::spawn(|| {
println!("hello from the spawned thread");
}
@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)
@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 / 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 / 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