Skip to content

Instantly share code, notes, and snippets.

View michaeljklein's full-sized avatar

Michael J Klein michaeljklein

View GitHub Profile

Data.Dynamic in Haskell

Haskell has Data.Dynamic: a method of hiding types in such a way that they may be conditionally resolved at run-time in a type-safe manner.

Here's the implementation in Haskell:

data Dynamic where
    Dynamic :: forall a. TypeRep a -> a -> Dynamic

TinyURL for this file: https://tinyurl.com/tezos-sfbw19

Setup

brew tap tqtezos/homebrew-tq https://github.com/tqtezos/homebrew-tq.git
brew install tezos
brew install lorentz-contract-param
brew install lorentz-contracts-sale
parameter (or (or (or (pair %transfer (address :from)
(pair (address :to)
(nat :value)))
(or (pair %transferViaProxy (address :sender)
(pair (address :from)
(pair (address :to)
(nat :value))))
(pair %approve (address :spender)
(nat :value))))
(or (pair %approveViaProxy (address :sender)

FA1.2.1 with PyTezos

This is a brief introduction to interacting with FA1.2.1 using PyTezos.

Install PyTezos

If on Linux, install dependencies with apt:

parameter (or (or (or (pair %transfer (address :from)
(pair (address :to)
(nat :value)))
(or (pair %transferViaProxy (address :sender)
(pair (address :from)
(pair (address :to)
(nat :value))))
(pair %approve (address :spender)
(nat :value))))
(or (pair %approveViaProxy (address :sender)
parameter (or (or (or (pair %transfer (address :from)
(pair (address :to)
(nat :value)))
(or (pair %transferViaProxy (address :sender)
(pair (address :from)
(pair (address :to)
(nat :value))))
(pair %approve (address :spender)
(nat :value))))
(or (pair %approveViaProxy (address :sender)

First, install the required dependencies using apt:

sudo apt update
sudo apt install clang curl git make build-essential

Next, install Homebrew for Linux:

@michaeljklein
michaeljklein / LambdaSelfTest.tz
Created September 10, 2019 19:07
Test on alphanet, demonstrating lack of support for SELF in lambda's
parameter (contract address);
storage unit;
code
{
UNPAIR;
DIP { DIP { LAMBDA unit address { DROP; SELF } }; EXEC };
SWAP;
DIP { AMOUNT };
{
"name": "erc-1155",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
» find ghc/testsuite/tests -type d -name "*.run_dir*" | wc -l                                                                                                                                                                                                $
7163
-- | `Nothing` if no change
type EditM = MaybeT (ReaderT DynFlags Hsc)

infixr 0 >-