Skip to content

Instantly share code, notes, and snippets.

View ssadler's full-sized avatar
🤍

Scott Sadler ssadler

🤍
  • utxocontracts.com
  • London, UK
View GitHub Profile
@ssadler
ssadler / shader.glsl
Last active August 16, 2024 20:31
shader.glsl
// FRAGMENT
#include <get_from_texture>
precision highp float;
//uniform float radius;
uniform vec3 color;
uniform float thickness;
uniform vec2 screenSize;
@ssadler
ssadler / outlines.tsx
Created August 16, 2024 17:48
Instanced Mesh
// Works
//
function simpleMesh() {
const mesh = new THREE.Mesh(geometry, material)
let b = beasties[1]
let c = b.getCell()
mesh.position.set(c.x, c.y, 0)
material.uniforms['radius'] = { value: c.r }
material.uniforms['screenSize'] = { value: screenSize }
material.uniforms['thickness'] = { value: 10 }
@ssadler
ssadler / Pack.sol
Created April 3, 2024 13:33
Lossy decimal pack uint96 to uint40
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.16;
library Balance {
uint constant internal BALBITS = 35;
uint constant internal EXPBITS = 5;
uint constant internal BALMAX = 2**35-1;
uint constant internal BALMAXS = 2**34-1;
uint constant internal SIGNED = 2**39;
@ssadler
ssadler / Provenance.sol
Last active August 17, 2023 13:54
Solidity code for cryptographic provenance verification
// See blog post: https://ssadler.substack.com/p/contract-provenance-verification-175
interface IProvenance {
function getProvenanceData() external returns (uint salt, bytes32 codeHash);
}
contract Provenance is IProvenance {
bytes32 immutable _salt;
bytes32 immutable _codeHash;
pragma solidity ^0.8.16;
import '../lib/diamond-3-hardhat/contracts/facets/DiamondCutFacet.sol';
import '../lib/diamond-3-hardhat/contracts/facets/OwnershipFacet.sol';
import '../lib/diamond-3-hardhat/contracts/facets/DiamondLoupeFacet.sol';
import '../lib/diamond-3-hardhat/contracts/libraries/LibDiamond.sol';
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC165.sol';
import '../lib/diamond-3-hardhat/contracts/interfaces/IERC173.sol';
contract QueryDiamond is OwnershipFacet, DiamondCutFacet, DiamondLoupeFacet {
@ssadler
ssadler / maple.hs
Last active January 19, 2021 21:01
Maple data structure concept
-- Maple data structure concept
-- Scott Sadler, 18/01/21
-- Int is an Ethereum 32 bit word
-- Sometimes entities appear denormalized but should all be referenced by ID, either numeric or hash, depending on context
-- Fields like created, modified date not present
-- Nearly all of this was garnered from the "how-can-i-borrow-on-maple" page
--
#!/usr/bin/env python3
import binascii
import gevent
import struct
from gevent import socket
def init_peer(peer, port):
sends = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sends.connect(peer)
@ssadler
ssadler / SaplingSigHash
Created June 19, 2020 22:40
Verify sapling tx sigs / sighashes
module SaplingSigHash where
import Data.Serialize
import Zeno.Prelude
import Zeno.Data.Hex
import qualified Haskoin as H
import Network.Komodo
import Network.ZCash.Sapling
module TestSecp256k1 where
import Network.Komodo
import Control.Monad
import Data.Serialize
import Network.Ethereum.Crypto
import Control.Concurrent
import Data.Word
import Control.Monad
import Control.Monad.Catch
import Test.DejaFu
import Test.DejaFu.Conc.Internal.Common
import Test.DejaFu.Conc.Internal.STM
import Control.Monad.Conc.Class
import Control.Concurrent.Classy hiding (wait)