Fetch Candid remotely

I would like to do fetch just the Candid for my canister remotely, while building everything else locally. Is this possible? I would like a dfx.json file that looks like this:

    "canisters": {
        "backend": {
            "type": "custom",
            "main": "src/backend/index.ts",
            "candid": "https://raw.githubusercontent.com/demergent-labs/azle/main/server.did",
            "build": "npx azle backend",
            "wasm": ".azle/backend/backend.wasm",
            "gzip": true,
            "assets": [["src/frontend/dist", "dist"]],
            "build_assets": "npm run build"

But unfortunately I get this error:

Error: ENOENT: no such file or directory, open 'https://raw.githubusercontent.com/demergent-labs/azle/main/server.did'
    at Object.openSync (node:fs:603:3)
    at writeFileSync (node:fs:2324:35)
    at /home/lastmjs/development/azle/src/compiler/index.ts:315:26
    at time (/home/lastmjs/development/azle/src/compiler/utils/time.ts:10:26)
    at azle (/home/lastmjs/development/azle/src/compiler/index.ts:110:15)
    at Object.<anonymous> (/home/lastmjs/development/azle/src/compiler/index.ts:32:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module.m._compile (/home/lastmjs/development/azle/node_modules/ts-node/src/index.ts:1365:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .ts] (/home/lastmjs/development/azle/node_modules/ts-node/src/index.ts:1368:12) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: 'https://raw.githubusercontent.com/demergent-labs/azle/main/server.did'

Not from dfx, but your build script can fetch it?

I don’t think this will work using the candid property in dfx, because dfx will try to find it and end in an error. I would have to create a custom property.

The remote canister feature allows something like this, that’s why I was hoping it might just work. Can we not allow URLs like this to work for Wasm and Candid even if the entire canister isn’t remote?

I mean the build script can fetch did file and the candid field will point to a local fetched file.

It feels a bit strange that a local project depends on an interface that is not local. How do we expect to update the interface, or what if the remote file is changed without developer noticing?

Similar problems with a fully remote canister aren’t they?

For custom canister types this is supported already (implemented in this PR). I can do the following just fine:

dfx new --type rust hello
cd hello

replace dfx.json with

  "canisters": {
    "hello_backend": {
      "candid": "https://raw.githubusercontent.com/demergent-labs/azle/main/server.did",
      "type": "custom",
      "build": [
        "cargo b -p hello_backend --target wasm32-unknown-unknown"
      "wasm": "target/wasm32-unknown-unknown/debug/hello_backend.wasm"
  "output_env_file": ".env",
  "version": 1

and then

dfx deploy
1 Like

So foolish of me, I didn’t even look into the stack trace to realize it was Azle’s retrieval of the Candid that was failing and not dfx’s.