Smart Contract | Module Publish

MSafe supports move module deployment. By using MSafe to deploy the smart contract, you will greatly reduce the risk of the single signed deployer account taking over the smart contract, and upgrade the smart contract to an arbitrary logic. By using momentum safe to publish a module, it will making the protocol code logics more secure and decentralized.

In this page, we will walk through the process of code deployment with the a MSafe wallet.

If you haven't created a MSafe wallet, please follow the instruction Create a MSafe Wallet to create a new MSafe wallet.

Initiate a module deploy

First, open an interactive CLI and select the MSafe wallet to deploy the MOVE module.

When entering MSafe details information, select n) New transaction

No pending transactions.

	n)	New transaction
	r)	Refresh
	b)	Back

Please input your option:		n

Choose 5) Module publish to select to publish a new module:

Please choose your transaction type

	1)	Transfer APT
	2)	Transfer COIN
	3)	Register COIN
	4)	Custom module interaction
	5)	Module publish

Please input your option:		5

--------------------

Start Module publish

Do you want to compile the MOVE module? [y/N]

Then the prompt will ask whether you want MSafe CLI to compile the MOVE module before publishing the module.

Compile

(Option 1) Choose not to compile MOVE module (default)

If you choose not to compile, you will need to compile the move module before continue.

  1. You will need to replace the deployer address in Move.toml with the multi-sig wallet address;

  2. You need to compile the MOVE module with specifying --save-metadata and --included-artifacts.

Please input your target move directory (with Move.toml)	./tests/move

Then input the move directory into and the CLI tool will load the move module for you.

(Option 2) Choose to let CLI compile MOVE module

If you choose to let CLI to compile the MOVE module for you, you will need to do the following prerequisites:

  1. You will need to have aptos cli in system $PATH. Check with which aptos.

  2. You will need to have deployer address value replaced with _. CLI will automatically configure the deploy address for you. E.g.

[addresses]
msafe = "_"

The CLI will prompt three inputs, and they are:

Please input your target move directory (with Move.toml)          ./tests/move
Included artifacts (none, sparse, all)                            sparse
Deployer address name in Move.toml                                msafe  
  1. Move code directory that contains file Move.toml.

  2. Included artifacts as compile arguments. The default compile option is sparse.

  3. Deployer address name as specified in Move.toml. In this case, msafe.

Then the CLI will compile the MOVE module for you, and the result will be shown after a successful compile.

Compiling:

	aptos move compile --package-dir=./tests/move --save-metadata --included-artifacts sparse --named-addresses msafe=0x43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa

Compile successful.
{
  "Result": [
    "43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa::message",
    "43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa::test_coin"
  ]
}

Publish module

After compile or load the MOVE from directory, the CLI will print the package information:

Transaction confirmation:

Action:			Module publish
Verify Hash:		0x721272356dad05365e8249024500458dc8c0deef7e34f85ef010e48b8122b2c3
Deployer:		0x43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa
Package:		MomentumSafe-test
Upgrade Policy:		compatible
Upgrade Number:		0
Source Digest:		BC36D67FB3DE5ABD5541BCAF633C28E1EFECF0DDDED20544296DCA98F744DE82
Modules:		0x43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa::message
			0x43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa::test_coin
Dependency:		0x0000000000000000000000000000000000000000000000000000000000000001::AptosFramework
			0x0000000000000000000000000000000000000000000000000000000000000001::AptosStdlib
			0x0000000000000000000000000000000000000000000000000000000000000001::MoveStdlib
Sender:			0x43b68d1027e84f0ca347ed633b87bb71437a5c50101b7f82b354b4ae7cc9d7aa
Sequence Number:	1
Expiration:		Thu Oct 06 2022 20:11:20 GMT-0700 (Pacific Daylight Time)
Gas Price:		100
Max Gas:		5000

--------------------

Transaction information correct? [Y/n]

Note that there is a Verify Hash in the confirmation which can be used to verify the deploy content for other owners.

Confirm with yes, and the transaction to initiate the module publish transaction is submitted on blockchain.

Confirm and sign for other owners

The other owners are able to sign and submit signatures either in CLI or Web App.

If the user want to sign in CLI, he may go to the corresponding wallet, select the module publish transaction, sign and submit the transaction on blockchain.

Pending transactions:

		| SN	| Action			| Confirmation	|

	1)	| 1	| Module publish		| 1 / 2
	n)	New transaction
	r)	Refresh
	b)	Back

Please input your option:

Last updated