Skip to main content

Folder Structure

The simplest folder structure of the default create-coinweb-dapp contract will look like the following tree illustration:

├── .cweb_tool
├── .cweb-config
│ ├── calls.yaml.template
│ ├── cweb-pack.yaml
│ ├── dapp-ecosystem.yaml
│ └── mnemonic.txt
├── package.json
├── packages
│ ├── dapp-ui
│ │ ├── package.json
│ │ └── src
│ │ └── index.js
│ └──
│ ├── package.json
│ └── src
│ ├── offchain
│ │ └── index.js
│ └── onchain
│ └── index.js
└── yarn.lock

This is a yarn workspaces setup with two packages, the contract module, and the dapp-ui which is a normal npm package.

.cweb_toolCaching folder for cweb-tool.
.cweb-configContains Coinweb internal configuration files explained in the module repo configuration.
packagesDefault yarn workspaces mono repo setup containing the separated packages/modules.
packages/hello-world.cmThe simplest Hello World smart contract module. Note the .cm convention to indicate a contract module.
packages/dapp-uiThis folder includes the selected and curated UI which is preset during create coinweb-dapp execution. onchain folder contains the logic of the smart contract that is ultimately published to Coinweb. offchain folder contains the source code that is used to interact with the smart contract from your dApplications front end or back end.

The contract module

The npm package resides in packages/ The suffix .cm in the package name is a convention often used by contract modules.

This package follows our contract module layout meaning that it consists of an onchain smart contract part, in src/onchain/, and an offchain authenticated code part, in src/offchain/. The offchain part is used to bundle code that relates to the smart contract but that should not execute as a smart contract.


In the hello world example, the smart contract onchain code simply writes a "hello world" claim to the claims db, while the offchain code exports functions that check if the correct claim was written.

The dApp User Intreface

A curated user interface example is located in the packages/dapp-ui directory.

The UI of the dApp is responsible for interacting with Coinweb (think the smart contracts onchain code) and the user. In the case of the hello world example, all the UI does is fetch the claim written by the smart contract, and invoke the offchain code from the contract module to verify that the claim was indeed written by the correct smart contract utilising the contract id.

In the end your dApp can be everything (a Javascript front end, a command line tool, an iOS App) and entirely independent of the actual contract module onchain code.

Please move on to see what the configuration files of a contract module look like.