Skip to content

Modules and Initialization

In Move, the closest code-level equivalent of a Solidity contract is a module.

pragma solidity ^0.8.20;
contract Billboard {
constructor(address owner_) {
// initialization
}
}
module billboard_address::billboard {
use std::signer;
/// Caller is not the module publisher.
const ENOT_AUTHORIZED: u64 = 1;
struct Billboard has key { /* fields */ }
entry fun initialize(owner: &signer) {
assert!(signer::address_of(owner) == @billboard_address, ENOT_AUTHORIZED);
move_to(owner, Billboard { /* ... */ });
}
}
  • Solidity declares contracts with the contract keyword. Move declares modules as address::module_name.
  • Solidity constructors run once at deployment. In Move, initialization is an explicit action invoked by the developer, giving them more control — over initialization order and over the separation of code from data (a core Move paradigm). An explicit entry fun initialize must be called by the publisher after publishing (see Modules on Aptos).
  • Package metadata and named addresses live in Move.toml, not inline in the module.
[package]
name = "billboard"
version = "1.0.0"
[addresses]
billboard_address = "_"

For production deployments, also evaluate deploying code as an object and package upgrade policy. The core migration point is that initialization is still explicit, but the packaging and address model are different.