0

Is there any kind of a constructor like function, which will run at the time of deployment in move programming language?

MikhilMC
  • 949
  • 3
  • 8
  • 14

1 Answers1

2

You might be looking for init_module. This function runs just when you publish your module.

An example:

fun init_module(sender: &signer) {
    aptos_framework::managed_coin::initialize<MoonCoin>(
        sender,
        b"Moon Coin",
        b"MOON",
        6,
        false,
    );
}

From aptos-move/move-examples/moon_coin/sources/MoonCoin.move in aptos-core.

You can learn more about it here: https://aptos.dev/move/move-on-aptos/modules-on-aptos/.

Daniel Porteous
  • 5,536
  • 3
  • 25
  • 44