Skip to content

Instantly share code, notes, and snippets.

@0xCourtney
0xCourtney / events.ts
Created July 8, 2022 14:20
Get event and event arguements emitted
async function getEvent(tx: any, event: string) {
let receipt = await tx.wait();
return receipt.events?.filter((x) => {
return x.event == event;
});
}
async function getEventArgs(tx: any, event: string) {
return (await getEvent(tx, event))[0].args;
}
@0xCourtney
0xCourtney / PRBMathRounding.sol
Last active June 21, 2023 18:03
Rounding with PRBMath
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {UD60x18} from "@prb/math/UD60x18.sol";
import {SD59x18} from "@prb/math/SD59x18.sol";
library PRBMathRounding {
SD59x18 constant iONE = SD59x18.wrap(1e18);
SD59x18 constant iTEN = SD59x18.wrap(10e18);
UD60x18 constant ONE_THOUSAND = UD60x18.wrap(1000e18);
@0xCourtney
0xCourtney / index.ts
Last active May 28, 2024 20:47
floodsub
import { noise } from '@chainsafe/libp2p-noise';
import { bootstrap } from '@libp2p/bootstrap';
import { tcp } from '@libp2p/tcp';
import { webSockets } from '@libp2p/websockets';
import { createLibp2p } from 'libp2p';
import { yamux } from '@chainsafe/libp2p-yamux';
import { floodsub } from '@libp2p/floodsub';
import { createFromJSON } from '@libp2p/peer-id-factory';
const node1 = {