Git Product home page Git Product logo

dfinity / examples Goto Github PK

View Code? Open in Web Editor NEW
502.0 50.0 317.0 84.67 MB

Example applications, microservices, and code samples for the Internet Computer

Home Page: https://dfinity.org

License: Apache License 2.0

JavaScript 25.55% Makefile 2.34% Shell 5.14% C 0.43% HTML 2.28% CSS 4.61% WebAssembly 0.24% Rust 16.38% Motoko 16.47% Svelte 12.41% Dockerfile 0.37% TypeScript 10.55% Python 0.13% Swift 0.88% Modelica 0.01% C# 2.09% Vue 0.13%
dfx icp blockchain microservices examples internet-computer

examples's People

Contributors

0xaegir avatar ais-dfn avatar benjaminloison avatar chenyan-dfinity avatar crusso avatar daniel-bloom-dfinity avatar dependabot[bot] avatar dfinity-berestovskyy avatar dfx-json avatar dprats avatar enzoh avatar ericswanson-dfinity avatar fspreiss avatar ielashi avatar jessiemongeon1 avatar krpeacock avatar letmejustputthishere avatar lsgunnlsgunn avatar matthewhammer avatar ninegua avatar qj-yu avatar robin-kunzler avatar rumenov avatar sea-snake avatar sesi200 avatar thlo avatar ulan avatar vincent-dfinity avatar yvonneanne avatar zhangwei983 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

examples's Issues

Unknown version '0.7.0-beta.6' - Mac.

running any dfx command inside any example directory throws this error:

Warning: The version of DFX used (0.7.0-beta.6) is different than the version being run (0.6.26).
This might happen because your dfx.json specifies an older version, or DFX_VERSION is set in your environment.
We are forwarding the command line to the old version. To disable this warning, set the DFX_WARNING=-version_check environment variable.

Error when trying to forward to project dfx:
Unknown version '0.7.0-beta.6'.
Installed executable: 0.6.26

Is there a command line to downgrade to a different version of the SDK?

NFT minting is missing the canisister id in the example. Breadcrumbsportal/docs/samples /nft.md

The step to deploy fails. It needs the canister id as the last argument:

dfx deploy --no-wallet --argument
"(record {
name = "Numbers One Through Fifty";
symbol = "NOTF";
logo = opt record {
data = "$(base64 -i ./logo.png)";
logo_type = "image/png";
};
custodians = opt vec { principal "$(dfx identity get-principal)" };
})" dip721_nft_container <<<<<<<<<<<<----- the canister name is required. Works when I added dip721_nft_container [I think].

frontend JS source maps are broken

dfx new first && cd first && npm install && dfx deploy

Deploying all canisters.
All canisters have already been created.
Building canisters...
Building frontend...
Installing canisters...
(...)
  /index.js.map 1/1 (952215 bytes)
  /index.js.map (gzip) 1/1 (254247 bytes)
Deployed canisters.

http://localhost:8000/?canisterId=ryjl3-tyaaa-aaaaa-aaaba-cai

Firefox F12 Consle:

Source map error: Error: request failed with status 500
Resource URL: http://localhost:8000/index.js
Source Map URL: index.js.map

From what little I understand about this, the build did seem to produce source maps, but for some reason they're not found; not sure what's missing.

pub_sub example won't work.

Hello there, I wanted to create a benchmark of this project and landed on the examples which looked promising.

However, this happened. It fails to build!

$ dfx canister create sub
Creating canister "sub"...
"sub" canister created with canister id: "do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q"
$ dfx canister create pub
Creating canister "pub"...
"pub" canister created with canister id: "6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q"
$ sh test.sh
Building canisters...
Build failed. Reason:
Build step failed for canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason:
Command "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/moc" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo" "-o" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/pub/pub.did" "--idl" "--actor-idl" "/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/.dfx/local/canisters/idl/" "--actor-alias" "pub" "6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--actor-alias" "sub" "do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/miguelemosreverte/.cache/dfinity/versions/0.6.10/base"
returned an error:
/home/miguelemosreverte/Desktop/motoko/examples/motoko/pubsub/src/pub/main.mo:8.1-22.2: type error, an actor or actor class must be the only non-imported declaration in a program
(This is a limitation of the current version.)

Installing code for canister pub, with canister_id 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q
An error occured:
Io(
Os {
code: 2,
kind: NotFound,
message: "No such file or directory",
},
)
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister 6ttj4-pafaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module
cannot find method type, dfx will send message with inferred type
Replica error (code 3): IC0304: Attempt to execute a message on canister do2cr-xieaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q which contains no Wasm module

Making sure the c compiler knows about standard libraries.

I'm trying to compile the duktape project to wasm to see if I can stuff it in a canister. I'm using the basic reverse.c example but I moved over the duktape.h and duktape.c files into the directory and changed the function to try to call something out of this. It turns out that the reason it can't compile is that it can't see the standard libraries for some reason.

root@ad0ec66809cb:/usr/src/examples/c/reverse# wcc reverse.c
In file included from reverse.c:1:
In file included from ./duktape.h:196:
./duk_config.h:865:10: fatal error: 'time.h' file not found
#include <time.h>
         ^~~~~~~~
1 error generated.

time.h is in /usr/include. Do I need to do something to tell the compiler to look there?

I'm currently running clang-11 --target=wasm32 -c -O reverse.c

The file is below(I'm expecting some type errors once I get past the imports):

#include "duktape.h"

#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
#define WASM_EXPORT(n) asm(n) __attribute__((visibility("default")))

int dfn_ads(void) WASM_IMPORT("ic0", "msg_arg_data_size");
void dfn_adc(void *, int, int) WASM_IMPORT("ic0", "msg_arg_data_copy");
void dfn_reply_append(void *, int) WASM_IMPORT("ic0", "msg_reply_data_append");
void dfn_reply(void) WASM_IMPORT("ic0", "msg_reply");
void dfn_print(void *, int) WASM_IMPORT("ic0", "debug_print");

void go() WASM_EXPORT("canister_update go");
void go() {
  char buf[128];
  int sz = dfn_ads();
  dfn_adc(buf, 0, sz);

  // Encoded string: "DIDL" 0 1 0x71 LEB128(length) data
  // So offset 7 holds string length (for short strings).
  int n = buf[7];
  
  duk_context *ctx = duk_create_heap_default();
  duk_eval_string(ctx, "'a string'");
  const char *str;

  str = duk_get_string(ctx, -3);
  
  dfn_print(str);
  dfn_reply_append(str, 8);
  dfn_reply();
}

Cannot find canister name "favorite-cities"

Running with the 0.5.7 SDK.

From the README:

dfx build
dfx canister install --all
dfx canister call favorite-cities location_pretty '(vec {"San Francisco";"Paris";"Rome"})'

I should observe the following result.

("Hello from San Francisco, Paris, Rome, bon voyage!")

Instead, I get:

favorite_cities ianblenke$ dfx build ; dfx canister install --all ; dfx canister call favorite-cities location_pretty '(vec {"San Francisco";"Paris";"Rome"})'
Building canisters...
Installing code for canister favorite_cities, with canister_id ic:6C2240B61A4B488A5F
An error occured:
CannotFindCanisterName(
    "favorite-cities",
)

Invoice Canister Cleanup Tasks

  • Ensure that person without viewing permission cannot view an already verified invoice
    • invoice.mo line 283
  • Gitignore src/declarations
  • replace dfx stop with `#!/usr/bin/env bash; set -e; dfx stop
  • Add access control for creating new invoices
  • Check account for transfer fee during transfer
    • ICPLedger.mo line 179
  • pull magic numbers into constants
    • main.mo line 139
  • Refactor permission checks to a method

A couple of errors and questions about the `examples` repo

Hi ICP folks,

  1. nft-wallet example failed to deploy locally

When I followed https://github.com/dfinity/examples/blob/master/rust/nft-wallet/README.md#step-1-you-can-deploy-the-dapp-using-the-startsh-script to deploy locally, I got the following error

created public/build/main.js in 12.8s
thread 'main' panicked at 'Could not create HTTP client.: reqwest::Error { kind: Builder, source: "Unknown TLS backend passed to `use_preconfigured_tls`" }', /Users/nanjiang/.cargo/registry/src/github.com-1ecc6299db9ec823/ic-agent-0.20.1/src/agent/http_transport/reqwest_transport.rs:79:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  1. Can I use dfx command to list all transactions in cycle?
    e.g. dfx wallet --network ic balance is for checking the total balance, but no transaction history.

Thanks and regards,

update dfx version 0.7.1→0.7.2

The version of each dfx in motoko/ is currently 0.7.1, but this is an old version!
We will need to update them to 0.7.2 as in #98.

We also need to consider updating some node.js packages.

calc example references dfx 0.5.2

Trying to start calc example with 0.5.7 SDK:

calc ianblenke$ dfx start
Warning: The version of DFX used (0.5.2) is different than the version being run (0.5.7).
This might happen because your dfx.json specifies an older version, or DFX_VERSION is set in your environment.
We are forwarding the command line to the old version. To disable this warning, set the DFX_WARNING=-version_check environment variable.

Error when trying to forward to project dfx:
CacheError(UnknownDfxVersion("0.5.2"))
Installed executable: 0.5.7

As a Developer, I want to know how to handle assets in the frontend so that I can modify my React app that way

Currently it is extremely hard to port an existing web app with lazy loaded javascript and images to IC and there is no elaborate example to show how to do that.

I'd love to see an example that shows how to lazy load assets. I am thinking here wasm modules, workers, images, etc.
It begins with using a custom html file, which I managed to get by injecting it, but a CRA webpack built React project contains so many assets, that there needs to be a easy way to manage them (also considering the fact, that via HMR development, the assets have to work in a normal browser env as well).

I tried several ways, but i.e. an CRA bootstrapped app doesn't seem to be portable to the IC right now without a lot of effort. A guideline on how to do this would be a major enabler for web devs.

Azle (TypeScript) examples

Azle is a TypeScript CDK for the Internet Computer. We've been creating many examples, some from this repo, here. Just wondering if you'd accept pull requests for examples written in TypeScript with Azle.

Jupyter app

@krzysztofwos suggested something like Jupyter notebooks.

I'm not quite sure what this means, because if you interpret code on the client-side, there's not much for the internet computer to do. We probably want to do at least smaller computations on the client-side because it'll respond much faster to small edits.

Perhaps it gets more interesting if we compute and store expensive results on the server side which can be then used in other notebooks?

I'm a little old-fashioned and insist that my own notes are usable offline. But cloud notebooks seem de rigeur nowadays, and we ought to demonstrate we can do something like Amazon's SageMaker Notebooks, Google's Colaboratory, or Microsoft's Azure Notebook.

Git submodule breaking on local for bitcoin dapp example

Following the steps from here: https://internetcomputer.org/docs/current/developer-docs/integrations/bitcoin/local-development

At step 3 when I run git submodule update --init --recursive

I get:

`gabriel@DESKTOP-8G906R5:~/projects/examples/motoko/basic_bitcoin$ git submodule update --init --recursive
Submodule 'QR-Code-generator' (https://github.com/nayuki/QR-Code-generator) registered for path '../../c/qr/QR-Code-generator'
Submodule 'motoko/basic_bitcoin/motoko-bitcoin' (https://github.com/tgalal/motoko-bitcoin) registered for path 'motoko-bitcoin'
Submodule 'motoko/defi/DIP20' (https://github.com/Psychedelic/DIP20.git) registered for path '../defi/src/DIP20'
Submodule 'rust/defi/DIP20' (https://github.com/Psychedelic/DIP20.git) registered for path '../../rust/defi/src/DIP20'
Submodule 'svelte/svelte-motoko-starter/internet-identity' (https://github.com/dfinity/internet-identity.git) registered for path '../../svelte/svelte-motoko-starter/internet-identity'
Submodule 'svelte/svelte-starter/internet-identity' (https://github.com/dfinity/internet-identity.git) registered for path '../../svelte/svelte-starter/internet-identity'
Cloning into '/home/gabriel/projects/examples/c/qr/QR-Code-generator'...
Cloning into '/home/gabriel/projects/examples/motoko/basic_bitcoin/motoko-bitcoin'...
Cloning into '/home/gabriel/projects/examples/motoko/defi/src/DIP20'...
Cloning into '/home/gabriel/projects/examples/rust/defi/src/DIP20'...
Cloning into '/home/gabriel/projects/examples/svelte/svelte-motoko-starter/internet-identity'...
Cloning into '/home/gabriel/projects/examples/svelte/svelte-starter/internet-identity'...
Submodule path '../../c/qr/QR-Code-generator': checked out 'fd6917601d0a77b6b6df81599118212d8cdb9a27'
Submodule path 'motoko-bitcoin': checked out '39debbd377f03d861f33a99888f1162e51ef9a21'
Submodule 'motoko-sha' ([email protected]:tgalal/motoko-sha.git) registered for path 'motoko-bitcoin/motoko-sha'
Cloning into '/home/gabriel/projects/examples/motoko/basic_bitcoin/motoko-bitcoin/motoko-sha'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:tgalal/motoko-sha.git' into submodule path '/home/gabriel/projects/examples/motoko/basic_bitcoin/motoko-bitcoin/motoko-sha' failed
Failed to clone 'motoko-sha'. Retry scheduled
Cloning into '/home/gabriel/projects/examples/motoko/basic_bitcoin/motoko-bitcoin/motoko-sha'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '[email protected]:tgalal/motoko-sha.git' into submodule path '/home/gabriel/projects/examples/motoko/basic_bitcoin/motoko-bitcoin/motoko-sha' failed
Failed to clone 'motoko-sha' a second time, aborting
Submodule path '../defi/src/DIP20': checked out '1d4b92781e46cee528e52f578c55e384561f380a'
Submodule path '../../rust/defi/src/DIP20': checked out 'cd365711ee4f34af9a6e74ca77d6637ee29d1755'
Submodule path '../../svelte/svelte-motoko-starter/internet-identity': checked out '58a63363b53b67f7d36c0002a3a0ab57dea4e4fb'
Submodule path '../../svelte/svelte-starter/internet-identity': checked out '58a63363b53b67f7d36c0002a3a0ab57dea4e4fb'
fatal: Failed to recurse into submodule path 'motoko-bitcoin'`

Rust example

I imagine it's technically possible to write a program in Rust and compile it to a Canister-compatible Wasm binary. It would be nice to have an official example in here which demonstrates this.

As a Developer, I want to Get Events so that My App Can React In Real Time

Is your feature request related to a problem? Please describe.
I'm looking at the Pub/Sub example and its pretty interesting but its just calling back to a subscriber class. If a user is running an app in a browser from a cannister it seems like it would need to poll the the subscriber function to look for updates. That's going to cost cycles and may infrequently change.

Describe the solution you'd like
I'd like to see an api where you can subscribe to an event published by an actor and an active socket connection is established. The actor could then publish a message to that event and matching subscribers would receive a message pushed from dfx through the socket in real-time.

Describe alternatives you've considered
Theoretically it could do something like support outbound webhook calls instead of requiring an active socket... that sounds worse for users behind firewalls but better for backend to backend. Maybe both would be good :)

Additional context
I'm new, maybe this already exists but I didn't see it in the docs. Pushing messages out of the system seems like a pretty important foundational piece, other systems support it in various ways.

SDK Update

**How do I get the seventh version?
Default install command sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" instaled version "latest": "0.6.26".
Examples are presented in the updated version

API
https://sdk.dfinity.org/manifest.json

{
"tags": {
"latest": "0.6.26"
},
"versions": [
"0.5.0",
"0.5.2",
"0.5.3",
"0.5.4",
"0.5.5",
"0.5.6",
"0.5.7",
"0.5.8",
"0.5.11",
"0.5.15",
"0.6.0",
"0.6.1",
"0.6.2",
"0.6.3",
"0.6.4",
"0.6.6",
"0.6.7",
"0.6.9",
"0.6.10",
"0.6.11",
"0.6.12",
"0.6.13",
"0.6.14",
"0.6.16",
"0.6.17",
"0.6.18",
"0.6.20",
"0.6.21",
"0.6.22",
"0.6.23",
"0.6.24",
"0.6.25",
"0.6.26",
"0.7.0-beta.0",
"0.7.0-beta.1",
"0.7.0-beta.2",
"0.7.0-beta.3",
"0.7.0-beta.4",
"0.7.0-beta.5",
"0.7.0-beta.6",
"0.7.0-beta.7",
"0.7.0-beta.8",
"0.7.0"
]
}

Reject text: The bitcoin API is not enabled on this subnet.

When following the basic_bitcoin example for Motoko as directed by @ielashi here,

despite this being enabled in dfx.json

"bitcoin": {
"enabled": true,
"nodes": [
"127.0.0.1:1844"
],

when I run dfx start --background I get

Running dfx start for version 0.12.1
Using the default definition for the 'local' shared network because /Users/user/.config/dfx/networks.json does not exist.
Dashboard: http://localhost:56516//dashboard 

And then on Candid I get this error:
Call was rejected:
Request ID: 712e1282edb7c3a8731caa265a8b8bf9458618a56c89610eb64495e492ef0040
Reject code: 4
Reject text: The bitcoin API is not enabled on this subnet.

Is the example broken? Why can't it connect to the local bitcoin network? I see this in the terminal running the bitcoin network:

2022-12-09T18:00:43Z 0 addresses found from DNS seeds
2022-12-09T18:00:43Z dnsseed thread exit
2022-12-09T18:01:44Z Adding fixed seeds as 60 seconds have passed and addrman is empty
<img width="968" alt="Screenshot 2022-12-09 at 18 14 21" src="https://user-images.githubusercontent.com/13382230/206768894-f47501d9-d917-4c8b-ac5c-5ba5fc4dd63a.png">

Coding Style

Hi,

please, be informed :

LINE : 06 Empty loop bodies should use {} or continue 
LINE : 16 Using C-style cast. Use reinterpret_cast<void *>(...) instead
LINE : 59 Do not use variable-length arrays. 
Use an appropriately named ('k' followed by CamelCase) compile-time constant for the size. 

BR,
Oleg

Windows support for SDK

Hey, all.
I have tried to find anything relative about Windows development.
I have tried to install SDK for windows but it throws error.
dfinity-sdk: unrecognized OS type: MINGW64_NT-10.0

Any work arounds? Or i will need to install Lunix subsystem

Failed to run hello-world sample

Hi, I have download SDK based on instructions and testing it with command

$dfx --version dfx 0.6.4

I clone examples motoko, from github and start to run hello-world based on instructions

  1. run $dfx start
    sudo dfx start ⠦ Checking replica! Aug 28 14:52:16.142 INFO ic-starter. Configuration: ValidatedConfig { node_id: 100, replica_path: Some("/root/.cache/dfinity/versions/0.6.4/replica"), subnet_id: 0, cargo_bin: "cargo", cargo_opts: "", state_dir: "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replicated_state", http_port_config: WritePortTo("/home/dimas/motoko/examples/motoko/hello-world/.dfx/client-configuration/client-1.port"), http_require_valid_signatures: true, artifact_pool_dir: "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replicated_state/node-100/ic_consensus_pool", crypto_root: "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replicated_state/node-100/crypto", state_manager_root: "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replicated_state/node-100/state", registry_file: "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replicated_state/node-100/registry.proto", state_dir_holder: None }, Application: starter Aug 28 14:52:16.142 INFO Executing "/root/.cache/dfinity/versions/0.6.4/replica" "/home/dimas/motoko/examples/motoko/hello-world/.dfx/state/replic⠒ Checking replica! Aug 28 14:52:16.525 WARN s:0/n:[100, 0, 0, 0, 0, 0, 0, 0, 253, 1]/ic_p2p/p2p P2P::process_messages(): processing msg_types = 1 Aug 28 14:52:16.525 ERRO s:0/n:[100, 0, 0, 0, 0, 0, 0, 0, 253, 1]/ic_messaging/xnet_endpoint No XNet configuration for node 5wjwg-gteaa-aaaaa-aaaap-2ai. This is an error in production, but may be ignored in single-subnet test deployments. Aug 28 14:52:16.525 WARN s:0/n:[100, 0, 0, 0, 0, 0, 0, 0, 253, 1]/ic_p2p/p2p P2P::process_messages(): processing msg_types = 4 Aug 28 14:52:16.526 WARN s:0/n:[100, 0, 0, 0, 0, 0, 0, 0, 253, 1]/ic_p2p/⠒ Replica bound at 35489 replica address: "http://localhost:35489" binding to: V4(127.0.0.1:8000) Internet Computer replica started...

  2. executing command $dfx build in another terminal
    sudo dfx build Building canisters... Build failed. Reason: Build step failed for canister 75hes-oqbaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason: Command "/root/.cache/dfinity/versions/0.6.4/moc" "/home/dimas/motoko/examples/motoko/hello-world/src/main.mo" "-o" "/home/dimas/motoko/examples/motoko/hello-world/.dfx/local/canisters/hello-world/hello-world.did" "--idl" "--actor-idl" "/home/dimas/motoko/examples/motoko/hello-world/.dfx/local/canisters/idl/" "--actor-alias" "hello-world" "75hes-oqbaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/root/.cache/dfinity/versions/0.6.4/base" returned an error: /home/dimas/motoko/examples/motoko/hello-world/src/main.mo:5.5-5.12: type error, field printLn does not exist in type module {nyi : () -> None; unreachable : () -> None; xxx : () -> None}

is there any that I missed?

As a Internet Computer application developer, I want to canister signature example so that to understand the certification

the certification and canister signature of Internet Computer, is very interesting features. I notice that certified data library, and it can be used to "story ICP", or can be used in canister signature. but both of certified data and is not so easy for understand. And I don't know how to use they. other info: https://sdk.dfinity.org/docs/interface-spec/index.html#_certificate

Describe the solution you'd like
I want a beautiful example which uses certified data and canister signature, and make an easier understanding. If it can "store" ICP, it will be even more wonderful. I am willing to spend some ICP to try this example on the mainnet.

Thanks!

Error: The replica returned an HTTP Error: Http Error: status 413 Payload Too Large

How to solve the following problem?

project location

/examples/rust/nft-wallet (master 0bb5b83)

error is

➜  nft-wallet git:(master) ✗ dfx deploy --no-wallet --argument null                                            (0s)[22-06-11 9:17:54]
Deploying all canisters.
All canisters have already been created.
Building canisters...
Executing './build.sh'
    Finished release [optimized] target(s) in 0.31s
Original:          3.02 MiB
Stripping Unused Data Segments...
    Size:          1.27 MiB (57.9% smaller)
Execute a binaryen optimization pass on your WASM....
    Size:          1.13 MiB (11.5% smaller)

Final Size: 1.13 MiB (62.8% smaller)
Installing canisters...
Installing code for canister internet_identity, with canister ID rdmx6-jaaaa-aaaaa-aaadq-cai
Error: The replica returned an HTTP Error: Http Error: status 413 Payload Too Large, content type "", content: Request 0xd765228fa7a682b37d54af9f59e86f1b050a70701d769cf659b686c80ea49041 is too large. Message byte size 2112149 is larger than the max allowed 2097152.

I found that because the wasm file internet-identity/internet_identity.wasm is too large.

➜  nft-wallet git:(master) ✗ ll -k internet-identity                                                           (0s)[22-06-11 9:34:33]
total 2068
-rw-r--r--  1 gaomingjun  staff     2993  6 10 11:36 internet_identity.did
-rwxr-xr-x  1 gaomingjun  staff  2111723  6 11 09:14 internet_identity.wasm

use version

dfx 0.10.0
rust 1.58.1

Compiling WASM with C/C++

Could we get an update or some more examples for the C example? For example, I'm trying to do the reverse example.
I start with a blank debian instance from docker. (I'll try to keep this list running and up to date for refference.

docker pull debian
docker run -ti debian

I run

apt-get install clang lld gcc-multilib

and I get a bunch of not found errors. A little research leads me to find that I need to run

apt-get update

Great so I do that and the install command works.

I run the alias commands and they register fine, but they won't run.

I don't have code because I'm in a docker container so:

apt-get install git
cd usr
cd src
git clone https://github.com/dfinity/examples.git
cd examples
cd c
cd reverse

now I run

wcc reverse.c

and get


reverse.c:16:19: warning: unknown attribute 'import_name' ignored [-Wunknown-attributes]
int dfn_ads(void) WASM_IMPORT("ic0", "msg_arg_data_size");
                  ^
reverse.c:13:75: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                                                          ^
reverse.c:16:19: warning: unknown attribute 'import_module' ignored [-Wunknown-attributes]
reverse.c:13:41: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                        ^
reverse.c:17:32: warning: unknown attribute 'import_name' ignored [-Wunknown-attributes]
void dfn_adc(void *, int, int) WASM_IMPORT("ic0", "msg_arg_data_copy");
                               ^
reverse.c:13:75: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                                                          ^
reverse.c:17:32: warning: unknown attribute 'import_module' ignored [-Wunknown-attributes]
reverse.c:13:41: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                        ^
reverse.c:18:36: warning: unknown attribute 'import_name' ignored [-Wunknown-attributes]
void dfn_reply_append(void *, int) WASM_IMPORT("ic0", "msg_reply_data_append");
                                   ^
reverse.c:13:75: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                                                          ^
reverse.c:18:36: warning: unknown attribute 'import_module' ignored [-Wunknown-attributes]
reverse.c:13:41: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                        ^
reverse.c:19:22: warning: unknown attribute 'import_name' ignored [-Wunknown-attributes]
void dfn_reply(void) WASM_IMPORT("ic0", "msg_reply");
                     ^
reverse.c:13:75: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                                                          ^
reverse.c:19:22: warning: unknown attribute 'import_module' ignored [-Wunknown-attributes]
reverse.c:13:41: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                        ^
reverse.c:20:29: warning: unknown attribute 'import_name' ignored [-Wunknown-attributes]
void dfn_print(void *, int) WASM_IMPORT("ic0", "debug_print");
                            ^
reverse.c:13:75: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));
                                                                          ^
reverse.c:20:29: warning: unknown attribute 'import_module' ignored [-Wunknown-attributes]
reverse.c:13:41: note: expanded from macro 'WASM_IMPORT'
#define WASM_IMPORT(m,n) __attribute__((import_module(m))) __attribute__((import_name(n)));

I'm guessing this is ok since they are all warnings.

when I run

wld reverse.o -o reverse.wasm

I get bash: wasm-ld-8: command not found.

Ok..so some investigation. In /usr/bin/ I have wasm-ld-7? Maybe I'll try:

alias wld="wasm-ld-7 --no-entry --export-dynamic --allow-undefined"

but that gets me wasm-ld-7: error: unknown argument: --export-dynamic

I'm guessing I need a newer version of wasm-ld? I google around a bit and find https://apt.llvm.org/ which gives me a script to run that includes wget. So

apt-get install wget
apt install lsb-release wget software-properties-common
bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"

Now I see wasm-ld-11 in my bin, but no 8. Lets give it a try anyway.

alias wld="wasm-ld-11 --no-entry --export-dynamic --allow-undefined"
wld reverse.o -o reverse.wasm

And I'm stuck here: wasm-ld-11: error: reverse.o: Unexpected metadata version: 1 (Expected: 2)

I'm not finding much info on the structure of the meta data or how to update it. I'm guessing it is the args in the reverse.c file, but I don't have much to go on for how to fix it.

I am unable to load image and css styles

I started learning dapps and my first program is in wsl ubuntu from windows10 using visual studio as editor where i am unable to load image and css in the page. Anyone help me to find the solution.
image

theorem prover

@krzysztofwos suggested a theorem prover. We can prove and store theorems and use them to prove more theorems, and since the IC is tamper-proof, we can trust all the results.

Like a trusted compiler app, this also needs some way for the anyone to retrieve the hash of a given canister.

error could not compile `typenum` due to 160 previous errors

When running

dfx deploy basic_bitcoin --argument '(variant { Regtest })'

at https://internetcomputer.org/docs/current/developer-docs/integrations/bitcoin/local-development

I'm getting

Some errors have detailed explanations: E0405, E0412, E0425, E0432, E0433, E0463.
For more information about an error, try rustc --explain E0405.
error: could not compile typenum due to 160 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
  Failed to build call canisters.
    Failed while trying to build all canisters.
      The build step failed for canister 'rkp4c-7iaaa-aaaaa-aaaca-cai' (basic_bitcoin) with an embedded error: Failed to build custom canister basic_bitcoin.: Failed to run src/basic_bitcoin/build.sh.: The custom tool failed.

collectible card game

@hansl suggested a collectible card game. The wild popularity of CryptoKitties comes to mind. DFINITY's better scaling properties means we ought to be able to create something better.

compiler app

dmd and others suggested a compiler app. The tamper-proof nature of the internet computer means you can trust the binary such a compiler produces, as long as you trust that the compiler's code is correct.

I've built a bunch of toy compilers that run on webpages. I could easily port one of them to DFINITY.

As for trusting the compiler's code: this requires some API call that lets anyone retrieve the hash of the wasm code powering a canister. (With this hash, it's then "merely" a matter of verifying the wasm code indeed compiles code correctly.)

1. Unity WebGL example needed better explanation. How to take build from Unity and integrate with ICP which is not understood from the existing sample

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

bug: CI is still using dfx 0.12.0

I tried upgrade to dfx 0.15.0-beta.0 for example, but then there is some issue with the provided node.js (which I don't grok). Perhaps some package-lock.json files need regenerating but I don't know how to do this properly.

I am running to a problem when running `dfx deploy`

alidante@HP-DESKTOP:~/code/project_name$ dfx deploy
Deploying all canisters.
Creating canisters...
Creating canister project_name_backend...
project_name_backend canister created with canister id: bd3sg-teaaa-aaaaa-qaaba-cai
Creating canister project_name_frontend...
project_name_frontend canister created with canister id: be2us-64aaa-aaaaa-qaabq-cai
Building canisters...
Executing 'npx azle project_name_backend'

Building canister project_name_backend

[1/4] 🔬 Performing initial research...
[2/4] 🛠️ Commencing development...
[3/4] 🖥️ Deploying...
[4/4] 🚀 Launching...
Error: Command failed: cd .azle/project_name_backend && /home/alidante/.config/azle/rust/1.73.0/bin/cargo build --target wasm32-wasi --manifest-path canister/Cargo.toml --release
Updating crates.io index
Updating git repository https://github.com/demergent-labs/ic-wasi-polyfill
Updating git repository https://github.com/ulan/javy.git
Updating git submodule https://github.com/web-platform-tests/wpt
error: failed to get quickjs-wasm-rs as a dependency of package canister v0.0.0 (/home/alidante/code/project_name/.azle/project_name_backend/canister)

Caused by:
failed to load source for dependency quickjs-wasm-rs

Caused by:
Unable to update https://github.com/ulan/javy.git?rev=fdf12ce4fd5636417cd63e1f6296aa79196434a7

Caused by:
failed to update submodule wpt/upstream

Caused by:
failed to fetch submodule wpt/upstream from https://github.com/web-platform-tests/wpt

Caused by:
network failure seems to have happened
if a proxy or similar is necessary net.git-fetch-with-cli may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
SSL error: unknown error; class=Ssl (16)

at checkExecSyncError (node:child_process:890:11)
at execSync (node:child_process:962:15)
at compileRustCode (/home/alidante/code/project_name/node_modules/azle/src/compiler/compile_rust_code.ts:14:13)
at /home/alidante/code/project_name/node_modules/azle/src/compiler/index.ts:135:28
at time (/home/alidante/code/project_name/node_modules/azle/src/compiler/utils/time.ts:10:26)
at azle (/home/alidante/code/project_name/node_modules/azle/src/compiler/index.ts:55:15)
at Object.<anonymous> (/home/alidante/code/project_name/node_modules/azle/src/compiler/index.ts:35:1)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module.m._compile (/home/alidante/code/project_name/node_modules/azle/node_modules/ts-node/src/index.ts:1365:23) {

status: 101,
signal: null,
output: [
null,
Buffer(0) [Uint8Array] [],
Buffer(997) [Uint8Array] [
32, 32, 32, 32, 85, 112, 100, 97, 116, 105, 110, 103,
32, 99, 114, 97, 116, 101, 115, 46, 105, 111, 32, 105,
110, 100, 101, 120, 10, 32, 32, 32, 32, 85, 112, 100,
97, 116, 105, 110, 103, 32, 103, 105, 116, 32, 114, 101,
112, 111, 115, 105, 116, 111, 114, 121, 32, 96, 104, 116,
116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98,
46, 99, 111, 109, 47, 100, 101, 109, 101, 114, 103, 101,
110, 116, 45, 108, 97, 98, 115, 47, 105, 99, 45, 119,
97, 115, 105, 45,
... 897 more items
]
],
pid: 2905,
stdout: Buffer(0) [Uint8Array] [],
stderr: Buffer(997) [Uint8Array] [
32, 32, 32, 32, 85, 112, 100, 97, 116, 105, 110, 103,
32, 99, 114, 97, 116, 101, 115, 46, 105, 111, 32, 105,
110, 100, 101, 120, 10, 32, 32, 32, 32, 85, 112, 100,
97, 116, 105, 110, 103, 32, 103, 105, 116, 32, 114, 101,
112, 111, 115, 105, 116, 111, 114, 121, 32, 96, 104, 116,
116, 112, 115, 58, 47, 47, 103, 105, 116, 104, 117, 98,
46, 99, 111, 109, 47, 100, 101, 109, 101, 114, 103, 101,
110, 116, 45, 108, 97, 98, 115, 47, 105, 99, 45, 119,
97, 115, 105, 45,
... 897 more items
]
}
Building frontend...
WARN: Generating type declarations for canister project_name_frontend:
/home/alidante/code/project_name/src/declarations/project_name_frontend/project_name_frontend.did.d.ts
/home/alidante/code/project_name/src/declarations/project_name_frontend/project_name_frontend.did.js
src/declarations/project_name_frontend/project_name_frontend.did
Generating type declarations for canister project_name_backend:
/home/alidante/code/project_name/src/declarations/project_name_backend/project_name_backend.did.d.ts
/home/alidante/code/project_name/src/declarations/project_name_backend/project_name_backend.did.js
src/declarations/project_name_backend/project_name_backend.did
../../node_modules/js-sha256/src/sha256.js (83:17) Use of eval in "../../node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.
../../node_modules/js-sha256/src/sha256.js (84:17) Use of eval in "../../node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.

Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to deploy canisters.
Failed to build all canisters.
Failed while trying to build all canisters.
The build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (project_name_backend) with an embedded error: Failed to build custom canister project_name_backend.: Failed to run npx azle project_name_backend.: The custom tool failed.

As a motoko dev, I want to use the dip721 standard so that i can deploy nft canisters using motoko

Is your feature request related to a problem? Please describe.
There is a Rust codebase for this, but no Motoko codebase. Motoko is the official language of the IC and more user friendly then Rust. The same example should be available for motoko as well.
https://github.com/dfinity/examples/tree/master/motoko/dip-721-nft-container

Describe the solution you'd like
Clone the Rust DIP721 example over to motoko.

Describe alternatives you've considered

Additional context

ToDo example doesn't work in dfx 0.6.7

It fails on build

alexander@alexander-ThinkPad-P52s:~/IdeaProjects/dfinity-examples/motoko/simple_to_do$ dfx build
Building canisters...
Build failed. Reason:
  Build step failed for canister 75hes-oqbaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q with error: Build failed. Reason:
  Command "/home/alexander/.cache/dfinity/versions/0.6.7/moc" "/home/alexander/IdeaProjects/dfinity-examples/motoko/simple_to_do/src/simple_to_do/main.mo" "-o" "/home/alexander/IdeaProjects/dfinity-examples/motoko/simple_to_do/.dfx/local/canisters/simple_to_do/simple_to_do.did" "--idl" "--actor-idl" "/home/alexander/IdeaProjects/dfinity-examples/motoko/simple_to_do/.dfx/local/canisters/idl/" "--actor-alias" "simple_to_do" "75hes-oqbaa-aaaaa-aaaaa-aaaaa-aaaaa-aaaaa-q" "--package" "base" "/home/alexander/.cache/dfinity/versions/0.6.7/base"
 returned an error:
/home/alexander/IdeaProjects/dfinity-examples/motoko/simple_to_do/src/simple_to_do/utils.mo:22.23-31.3: type error, expression of type
  ToDo/1 -> ToDo/1
cannot produce expected type
  [ToDo/1]
/home/alexander/IdeaProjects/dfinity-examples/motoko/simple_to_do/src/simple_to_do/utils.mo:31.5-31.10: type error, expression of type
  [ToDo/1]
cannot produce expected type
  ToDo/1 -> ToDo/1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.