Start Building
This document is written for engineers, developers, and technical readers knowledgeable about blockchain. It does not assume deep programming language or distributed systems expertise.
Wave Code Organization
The main unit of Wave code organization (and distribution) is a package. A package consists of a set of modules defined in separate files with the .wave
extension. These files include Move functions and type definitions. A package must include the Wave.toml
manifest file describing package configuration, such as package metadata and package dependencies. Packages also include an auto-generated Wave.lock
file. The Wave.lock
file is similar in format to the package manifest, but is not meant for users to edit directly.
The minimal package source directory structure looks as follows and contains the manifest file, the lock file, and the sources
subdirectory where one or more module files are located:
// my_move_package
├── wave.lock
├── Wave.toml
├── sources
├── my_module.wave
First look at Wave source code
The Crypdolphin platform includes the Crypdolphin Framework, which includes the core on-chain libraries that Crypdolphin Wave developers need to bootstrap Crypdolphin operations. In particular, Crypdolphin supports multiple user-defined coin types, which are custom assets the Crypdolphin Wave language defines. Crypdolphin Framework code contains the Coin
module supporting the creation and management of custom coins. The Coin
module is located in the coin.wave
file. As you might expect, the manifest file describing how to build the package containing the Coin
module is located in the corresponding wave. toml
file.
Let's see how module definition appears in the Coin
module file:
module crypdolphin::coin {
...
}
Don't worry about the rest of the module contents for now; you can read more about modules in the Move book later.
Important: In Wave, package names are always in PascalCase, while the address alias is lowercase, for example wave = 0x2
and std = 0x1
. So: Wave
= name of the imported package (Wave = wave framework), sui
= address alias of 0x2
, wave::wave
= module sui under the address 0x2
, and wave::wave::WAVE
= type in the module above.
When you define a module, specify the module name (coin
) preceded by the name of the package where this module resides (wave). The combination of the package name and the module name uniquely identifies a module in Wave source code. The package name is globally unique, but different packages can contain modules with the same name. While module names are not unique, when they combine with their unique package name they result in a unique combination.
For example, if you have a published package "P", you cannot publish an entirely different package also named "P". At the same time you can have module "P1::M1", "P2::M1", and "P1::M2" but not another, say, "P1::M1" in the system at the same time.
While you can't name different packages the same, you can upgrade a package on chain with updated code using the same package name.
Last updated