Skip to content

Instantly share code, notes, and snippets.

View letmejustputthishere's full-sized avatar

Moritz Fuller letmejustputthishere

View GitHub Profile
@3cL1p5e7
3cL1p5e7 / useUploader.tsx
Created March 23, 2022 17:53
IC certified assets uploader hook
import {ActorSubclass} from '@dfinity/agent';
import { useCallback, useEffect, useState } from 'react';
import cryptoJS from 'crypto-js';
import type { _SERVICE } from 'PATH_TO_SERTIFIED_ASSETS_TS_IDL';
export interface UseUploaderProps {
canister: ActorSubclass<_SERVICE>;
chunkSize?: number;
chunksPerOperation?: number;
progress?(stats: Stats): any;
@peterpeterparker
peterpeterparker / ic-bundle-static-files.mjs
Last active November 2, 2023 10:37
Bundle static files in Motoko canisters
#!/usr/bin/env node
import {writeFile} from 'fs/promises';
import {Blob} from 'node:buffer';
import fetch from 'node-fetch';
const fetchData = async (url) => {
const response = await fetch(url);
@nomeata
nomeata / main.mo.md
Created September 15, 2021 16:34
Certified Assets from Motoko (PoC/Tutorial)

Every now and then someone asks whether Motoko canisters can use certified variables, or whether they can serve HTTP requests with certification, and I always responded that yes, Motoko can do that, all that’s missing are a few libraries. But I figured I should put my hand where my mouth is, and actually demonstrate that it’s possible.

So here we go. If you go to https://ce7vw-haaaa-aaaai-aanva-cai.ic0.app/ you will see that

To prove the latter claim, here is the commented code; you can also browse the full repository.

main.mo

@krpeacock
krpeacock / create_canister.rs
Created August 20, 2021 18:31
Create canister from dfx
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::ic_attributes::CanisterSettings;
use crate::lib::identity::identity_utils::CallSender;
use crate::lib::identity::Identity;
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::provider::get_network_context;
use crate::lib::waiter::waiter_with_timeout;
use anyhow::anyhow;
@SuddenlyHazel
SuddenlyHazel / nft-0.0.1.did
Created July 29, 2021 20:06
nft-0.0.1.did
type Value =
variant {
Bool: bool;
Class: vec Property;
Empty;
Float: float64;
Int: int;
Nat: nat;
Principal: principal;
Text: text;