function generateTrait(trait_type, distributions, values) { | |
const sum = distributions.reduce((prv,cur) => (cur + prv), 0); | |
if (sum !== 10000) throw ("probabilites don't add up to 100%"); | |
const traitRandomness = 10000 * p5.random(); | |
let probability = 10000; | |
for (const i in distributions) { | |
probability -= distributions[i] | |
if (traitRandomness > probability) { | |
return { trait_type, value: values[i] } | |
} |
import { ERC721 as ERC721Contract } from '../generated/Splice/ERC721'; | |
import { Bytes, ByteArray, ethereum } from '@graphprotocol/graph-ts'; | |
import { Splice, Style } from '../generated/schema'; | |
import { Minted, Splice as SpliceContract } from '../generated/Splice/Splice'; | |
export function handleMinted(event: Minted): void { | |
const tokenId = event.params.token_id.toString(); | |
const splice = new Splice(tokenId); | |
const spliceContract = SpliceContract.bind(event.address); |
const { ethers } = require("ethers"); | |
const abi = require("./storage.abi.json"); | |
const INFURA_KEY = "..."; //get at https://infura.io/product/ethereum | |
const CONTRACT_ADDRESS = "0x7DA77f8a834369dDc5e9e47407C9746Ed55C3b72"; | |
const provider = new ethers.providers.InfuraProvider(42, INFURA_KEY); | |
const contract = new ethers.Contract(CONTRACT_ADDRESS, abi, provider); | |
(async function main() { |
[ | |
{ | |
"inputs": [], | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ |
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8; | |
import '@openzeppelin/contracts/access/Ownable.sol'; | |
contract Storage is Ownable { | |
uint256 number; | |
constructor() Ownable() {} |
import CeramicClient from "@ceramicnetwork/http-client"; | |
import { IDX } from "@ceramicstudio/idx"; | |
import { Ed25519Provider } from "key-did-provider-ed25519"; | |
import KeyResolver from "key-did-resolver"; | |
import { DID } from "dids"; | |
const seed = Buffer.from("c7943d32...d6edfcd","hex"); //32 random bytes | |
const did = new DID({ | |
provider: new Ed25519Provider(seed), | |
resolver: KeyResolver.getResolver(), |
An SMTP compat "mail" client that uses Ceramic documents to sync & relay mail-like messages between identities. Roughly related to did-comm.
The fundamental idea of a self sovereign identity is the "DID", a decentralized identifier, looking like did:key:zkmanycharacters
. DIDs are uniquely identified by key material of an user, derived by some random seed only the user knows. DIDs can be resolved / expanded to DID documents that contain information about the public keys a user uses for communication and authentication purposes.
At its core, the Ceramic protocol uses DIDs to represent identities that are interacting with documents, atm did:3 and did:key are supported: https://developers.ceramic.network/learn/overview/#authentication. On top of Ceramic, IDX is adding a layer of well formed documents that contain additional information about the user, e.g. an user "profile".
[package] | |
name = "testssl" | |
version = "0.1.0" | |
authors = ["Stefan Adolf <[email protected]>"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
reqwest = { version = "0.11.3", features = ["json"] } |
const inp = 'b44861ea32a51020'; | |
console.log(inp); | |
const square0 = Square.fromBytes(Buffer.from(inp, 'hex')); | |
Square.print(square0); | |
const bits = Square.toBinArray(square0); | |
console.log(bits); | |
const bytes = Square.bitsToBytes(bits); | |
console.log(bytes.toString("hex")); | |
//const square1 = Square.fromBytes(randBuffer(8)); |