Skip to content

Instantly share code, notes, and snippets.

@joaostein
joaostein / StatusExample.sol
Created October 31, 2022 09:17
Simple `_status()` implementation using enum
//SPDX-License-Identifier: Unlicense
pragma solidity 0.8.17;
contract StatusExample {
enum Status {
Active,
Succeeded,
Failed,
Canceled
@joaostein
joaostein / getGasUsed.js
Last active October 21, 2022 20:53
example of `getGasUsed` helper function
// helper function (you can create your own `helpers.js` file and import to your tests)
const getGasUsed = async (tx) => {
const { gasUsed, effectiveGasPrice } = await tx.wait();
return gasUsed.mul(effectiveGasPrice);
};
// your tests
describe('how to calculate and consider gas costs', () => {
const oneEth = ethers.utils.parseEther('1');
// deposit `oneEth`
@joaostein
joaostein / open-video
Created February 23, 2016 20:54
open-video
javascript:(function () {
var doc = document.querySelectorAll('.mwEmbedKalturaIframe')[0].contentWindow.document;
var video = doc.querySelectorAll('.videoDisplay video');
var videoUrl = video[0].getAttribute('src');
console.log(videoUrl);
window.open(videoUrl, '_blank');
}());
@joaostein
joaostein / .gitignore
Created January 5, 2014 01:45
Useful boilerplate files
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
Icon
# Thumbnails
._*
# Files that might appear on external disk