Build & publish your first dApp
This is the full path from an empty folder to a confidential dApp registered on the network: scaffold, write a backend function, prove it locally, bake it into an enclave, publish. Every step uses one command, and nothing costs gas until the very last one.
Before starting, make sure your toolchain is ready — see Environment Prerequisites.
1. Scaffold — ecld-init
Install the SDK and initialize the project. Python:
pip install ethernity-cloud-sdk-py
ecld-initJavaScript:
npm install @ethernity-cloud/sdk-js
npx ecld-initAnswer the prompts: a project name (this becomes your enclave's on-chain name), the network (default Bloxberg Testnet — the right place to start), the service type, and whether to enable the Enclave State Registry (say yes if your dApp needs state that persists between tasks — see Managing dApp State (ESR)).
This writes your project config and scaffolds src/serverless/ — the code that will run inside the enclave.
2. Write your backend
Your dApp's functions live in src/serverless/backend.py (or backend.js). Every exported function becomes callable from a task payload — the string a client submits.
# src/serverless/backend.py
def hello(msg="World"):
return "Hello " + msg// src/serverless/backend.js
function hello(msg = 'World') {
return 'Hello ' + msg;
}
module.exports = { hello };Return plain data — it is encoded automatically (JSON for objects, text for strings, base64 for bytes). To attach persistent state to the result, return through ecld_result(...) — see the ESR page.
3. Prove the call locally — ecld-test
Before building anything, run your function with the enclave's own executor — instant, no SGX, no gas:
This catches wrong names, bad arguments, and broken imports before anything is paid for. If your backend uses ESR, the state registry is emulated locally, on by default. Full reference: Running your dApp.
4. Bake the enclave — ecld-build
This bakes your backend into the securelock enclave image (Docker required). It also refuses unsafe patterns — dynamic execution of task input — and, for ESR projects, fills in the correct registry contract for your network. The result is an attestable image whose measurement will be registered on-chain, so the network can verify a node runs your exact, untampered code.
5. Publish — ecld-publish
This registers your enclaves in the on-chain Image Registry: certificates are extracted, the image goes to IPFS, and the registration transaction is paid by your wallet — so you need testnet tokens first: grab them free at the Testnet Faucet.
Confirm it landed — free, read-only:
Both enclaves should show published and validated — see Inspecting your dApp.
6. Run it on the network
Your code executes inside a real SGX enclave on a network node, and the decrypted result comes back to your terminal. From here:
Running your dApp — the full
ecld-test/ecld-runreferenceManaging dApp State (ESR) — give your dApp durable, encrypted state
Step-by-Step dApp — put a web frontend on what you just published
Last updated