How I Learned to Stop Wor…

v32

(* This objkt lives on the Tezos blockchain at the mainnet deployment of the *) (* contract below @ KT1Wp7s3jN31AbcCMinxRSrBtb4dYnBF5Pc7 *) (* *) (* api.tzkt.io/v1/contracts/{address}/bigmaps/705519/keys/{CIDv0} *) (* *) (* For convenience, other services/servers may also provide you with a copy. *) (* *) (* Use of this contract to store arbitrarily large amounts of data is left *) (* as an exercise and is not recommended. *) (* see: https://ex.rs/thoughts-on-inscriptions *) (* This is free and unencumbered software released into the public domain. For more information, please refer to <https://unlicense.org/> *) module SmolPinner = struct type storage = (string, bytes) big_map type ret = operation list * storage (* https://protobuf.dev/programming-guides/encoding/ *) let rec varint (n : nat) : bytes = if n < 128n then bytes n else Bytes.concat (((bytes n) land 0x7F) lor 0x80) (varint (n lsr 7n)) (* https://docs.ipfs.tech/concepts/file-systems/#unix-file-system-unixfs *) let pack (file : bytes) : bytes = let fs = Bytes.size file in let fsVarint = varint fs in let fsVarintSize = Bytes.size fsVarint in Bytes.concats [ 0x0A; varint ((2n*(2n+fsVarintSize))+fs); 0x0802; 0x12; fsVarint; file; 0x18; fsVarint] let b58charset = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" let getchar (i : nat) : string = String.sub i 1n b58charset let rec b58enc (n : nat) : string = if n = 0n then "" else String.concat (b58enc (n/58n)) (getchar (n mod 58n)) [@entry] let pinFile (file : bytes) (store : storage) : ret = let multihash = Bytes.concat 0x1220 (Crypto.sha256 (pack file)) in [], Big_map.add (b58enc (nat multihash)) file store end

H=N OBJKT
#863990
Editions

0/0

Royalties

15%

MIME type

text/plain

    No items