Skip to main content

Managing MVR Names

caution

The TypeScript examples assume that you use the MVR plugin for the Sui TypeScript SDK. The Sui CLI examples do not use the MVR plugin.

Create a new application

To create a new application, you must provide a SuiNS name and a package name, as long as it is not already registered.

const transaction = new Transaction();

const appCap = transaction.moveCall({
target: `@mvr/core::move_registry::register`,
arguments: [
// the registry obj: Can also be resolved as `registry-obj@mvr` from Mainnet SuiNS.
transaction.object('0x0e5d473a055b6b7d014af557a13ad9075157fdc19b6d51562a18511afd397727'),
transaction.object(suinsObjectId),
transaction.pure.string(name),
transaction.object.clock(),
],
});

// You can then use the appCap to attach packages directly, or transfer (for example to a safe address)
// and register packages later.

Set application metadata

Metadata is strongly recommended for any application. Provide the appCap along with a key-value pair. Key can be description, icon_url, documentation_url, homepage_url, or contact.

const transaction = new Transaction();

transaction.moveCall({
target: `@mvr/core::move_registry::set_metadata`,
arguments: [
// the registry obj: Can also be resolved as `registry-obj@mvr` from Mainnet SuiNS.
transaction.object('0x0e5d473a055b6b7d014af557a13ad9075157fdc19b6d51562a18511afd397727'), // Move registry
appCap,
transaction.pure.string("description"), // key
transaction.pure.string("<Description for the application>"), // value
],
});

Attach a Mainnet package to an application

When attaching a Mainnet package to an application, you must provide the PackageInfo object. This call is permanent, so after you attach a PackageInfo object to an application, you cannot detach it in the future. Consequently, an app is always linked to a specific package.

// You can then use the appCap to attach packages directly, or transfer (for example to a safe address)
// and register packages later.

const transaction = new Transaction();

transaction.moveCall({
target: `@mvr/core::move_registry::assign_package`,
arguments: [
// the registry obj: Can also be resolved as `registry-obj@mvr` from Mainnet SuiNS.
transaction.object(`0x0e5d473a055b6b7d014af557a13ad9075157fdc19b6d51562a18511afd397727`),
transaction.object('<The AppCap object>'),
transaction.object('<The PackageInfo object on Mainnet>'),
],
});

Attach a non-Mainnet package to an application

For non-Mainnet networks, you only attach a pointer to the package, instead of strict binding (which would not be possible).

info

You can always update an external network by first calling @mvr/core::move_registry::unset_network, and then calling @mvr/core::move_registry::set_network again.

const transaction = new Transaction();

const appInfo = transaction.moveCall({
target: `@mvr/core::app_info::new`,
arguments: [
transaction.pure.option("address", '<The objectId of the `PackageInfo` object on the external network>'),
transaction.pure.option("address", '<The address of the package on the external network>'),
transaction.pure.option("address", null),
],
});

transaction.moveCall({
target: `@mvr/core::move_registry::set_network`,
arguments: [
// the registry obj: Can also be resolved as `registry-obj@mvr` from Mainnet SuiNS.
transaction.object('0x0e5d473a055b6b7d014af557a13ad9075157fdc19b6d51562a18511afd397727'),
transaction.object('<The AppCap object>'),
transaction.pure.string("<chain id of the network: use `4c78adac` for Testnet>"),
appInfo,
],
});