Skip to main content

Create a Dynamic Notarization

Create a Dynamic Notarization

This guide will walk you through the process of creating a Dynamic Notarization and publishing it to an IOTA network. Dynamic notarizations are mutable, allowing you to update their state and metadata after creation, and they can be transferred between addresses.

1. Get Funded Notarization Client

To create a Dynamic Notarization, you need access to an IOTA network or run a local IOTA network.

In test networks as well as local ones, you can use a faucet to request funds. In the IOTA mainnet you will need an address with enough funds to cover the gas cost of the whole procedure.

tip

If you want to use the main IOTA network, you will need an address with actual IOTA funds to create a new Dynamic Notarization.

The example code below demonstrates using a faucet to receive funds before the example code is run.

This is how to create a notarization client and call a utility function explained below to fund the test account.

examples/utils/utils.rs
loading...
pub async fn get_notarization_read_only_client() -> anyhow::Result<NotarizationClientReadOnly> {
let iota_client = get_iota_client().await?;

let package_id = get_package_id_from_env("IOTA_NOTARIZATION_PKG_ID")?;

NotarizationClientReadOnly::new_with_pkg_id(iota_client, package_id)
.await
.context("failed to create a read-only NotarizationClient")
}

The utility function to fund the test account is implemented this way:

product_common/src/test_utils/utils.rs
loading...
fn unpack_command_output(output: &Output, task: &str) -> anyhow::Result<String> {
let stdout = std::str::from_utf8(&output.stdout)?;
if !output.status.success() {
let stderr = std::str::from_utf8(&output.stderr)?;
anyhow::bail!("Failed to {task}: {stdout}, {stderr}");
}

Ok(stdout.to_string())
}

Note:

2. Create a Simple Dynamic Notarization

The simplest form of a Dynamic Notarization can be created without any locks, making it fully mutable and transferable.

examples/02_create_dynamic_notarization.rs
loading...
note
  • The build_and_execute() (resp. buildAndExecute()) method is called to publish the Dynamic Notarization.
  • The finish() method is called to build the transaction which will create the Dynamic Notarization when being processed by an IOTA node.

3. Create a Dynamic Notarization with Transfer Lock

You can also create a Dynamic Notarization with a transfer lock to prevent transfers until a specified time.

examples/02_create_dynamic_notarization.rs
loading...

End Result

The end result will be a Dynamic Notarization object that is published to the IOTA network. Unlike locked notarizations, dynamic notarizations can be:

  • Updated: State and metadata can be modified after creation
  • Transferred: Ownership can be transferred to other addresses (unless transfer-locked)
  • Versioned: Each state update increments the version counter

Transfer Lock Types

Dynamic notarizations support optional transfer locks:

  • None: No transfer restrictions (default)
  • UnlockAt(timestamp): Locked until specified timestamp
  • UntilDestroyed: Locked until notarization is destroyed

Full Example Code

examples/02_create_dynamic_notarization.rs
loading...

Running Examples Locally

In order to run the examples, you will need to run an IOTA network locally.

If you want to use something different, you will need to modify the API and faucet endpoints in the examples to match your setup.