Skip to main content

Module Configuration

The Coinweb contract module configuration mainly consists of internal .yaml configuration files. The following will explain each of the files used in a contract module setup.

Coinweb Configuration Folder

The folder .cweb-config at the monorepo's root level keeps general Coinweb configuration files.

.cweb-config
├── calls-template.yaml
├── calls.yaml
├── create-calls.mjs
├── cweb-pack.yaml
├── dapp-ecosystem.yaml
├── mnemonic.txt
└── unsafe_wallet_mnemonic
FileDescription
calls-template.yamlAggregates all call files from different contract modules under packages/*.cm
calls.yamlGenerated .yaml file from aggregated call configurations in calls-tamplate.yaml
create-calls.mjsScript that aggregates all calls via calls-template.yaml into calls.yaml
cweb-pack.yamlConfiguration .yaml file for the @coinweb/cweb-tool pack command which is part of the @coinweb/cweb-tool
dapp-ecosystem.yamlInternal configuration .yaml file for Coinweb contract modules
mnemonic.txtThe general/main Coinweb wallet that will be considered for all interactions with the contract modules directly or indirectly. This file carries a default DEVNET seed phrase. Be careful working with seed phrases in production environment.
unsafe_wallet_mnemonicThis is an auto-generated temporary wallet used to ultimately execute actions. It exists because of security reasons and will be generated if missing and/or topped up from the main mnemonic.txt wallet when needed.

calls-template.yaml

The calls template includes all contract modules' configuration calls.yaml files to generate the root calls.yaml file.

calls-template.yaml
calls:
- !include packages/hello-world.cm/deploy/.calls-package.yaml

calls.yaml

The root calls.yaml file generated from calls-template.yaml. In case of the hello-world.cm it consists of only one call containing the hash of the contract.

calls.yaml
calls:
- 221b344e9e801f1106e2769e6ff7fc9be9947aa9e1ad65fb82c607d32560cc67:
args:
- DEFAULT
- {}
cweb_provided: 80000
auth: false

Each contract hash is associated with a map in the following format:

KeyValue
argsA list of arguments to provide when calling the contract.
cweb_providedAmount of CWEBs needed to provide for contract execution.
authBoolean that indicates whether authentication for the given contract is obligatory.

create-calls.mjs

Create-calls.mjs is a Javascript (ESM) script that transpiles the calls-template.yaml into calls.yaml.

create-calls.mjs
const callsTemplateJSON = yaml.load(
fsSync.readFileSync(
path.join(workdirPath, '/.cweb-config/calls-template.yaml'),
'utf8'
),
{ schema: extendedSchema }
);

fsSync.writeFileSync(
path.join(workdirPath, '/.cweb-config/calls.yaml'),
yaml.dump(callsTemplateJSON),
{ encoding: 'utf8' }
);

cweb-pack.yaml

cweb-pack.yaml
known_dapps_index:
url: >-
https://gitlab.com/api/v4/projects/47807501/packages/generic/contract_indexes/0.0.6/in_house_ecosystem_index.yaml
blake3: dd71f72c924435a9e8698734ba859b2b1d2f543926a64a60f9b7feb5b029123b
KeyValue
urlThe currently used ecosystem in form of a yaml file.
blake3The blake 3 hash of the ecosystem file that is in use.

dapp-ecosystem.yaml

This is a "index source" that specifies the dApp world as you see it. This index defines what interpreters, contract templates etc you want to use, and what they should be called. You can include external sources for this information in the includes section, and you include your own smart contract in the contract_templates section.

The following illustrated the configuration in the hello-world.cm example.

dapp-ecosystem.yaml
# We currently use a reference to the Coinweb in-house ecosystem definition file for devnet.
includes:
- url: >-
https://gitlab.com/api/v4/projects/47807501/packages/generic/contract_indexes/0.0.6/in_house_ecosystem_index.yaml
blake3: dd71f72c924435a9e8698734ba859b2b1d2f543926a64a60f9b7feb5b029123b

interpreters: {}

contract_templates:
# Our contract module. The contract module is an npm package created in the `dist/out`
# directory using the `yarn build` and `yarn pack` commands.
- file:///./packages/hello-world.cm/dist/out/my-contract-module.tgz

mnemonic.txt

Mnemonic.txt contains a Coinweb seed phrase that is used for the execution of all actions. In the case of the hello-world contract it is just some arbitrary default DEVNET seed phrase.

mnemonic.txt
priority supply couple broccoli balcony sort flag keep original wrong pottery version
danger

Be careful not to expose the seed phrase when committing code to production. It is better to set them up in you environment files.

unsafe_wallet_mnemonic

The unsafe wallet is just a middleman that is used for security reasons when interacting with Coinweb. If it does not exist it will be created by the cweb-tool. If it exists it will be used for all upcoming actions. If the balance is less than the needed balance for the execution of an action it will be topped up from the main mnemonic wallet

unsafe_wallet_mnemonic
baby pair impose hybrid reform network cream suspect better flash asthma oil

Coinweb © 2024