Update State in Dynamic Notarizations
Update State in Dynamic Notarizations
This guide demonstrates how to update the state of a Dynamic Notarization. Unlike locked notarizations, dynamic notarizations allow you to modify their content and state metadata after creation.
Prerequisites
- A Dynamic Notarization already created and published to the IOTA network
- The notarization must not be update-locked
- Sufficient funds for gas costs
1. Get the Notarization Client
First, ensure you have a funded notarization client with the necessary permissions to update the notarization.
2. Create a Dynamic Notarization for Testing
If you don't have an existing dynamic notarization, create one first:
3. Check Current State
Before updating, you can inspect the current state of the notarization:
4. Update the State
Update the state with new content and metadata:
5. Verify the Update
After updating, verify that the changes were applied successfully:
Key Features of State Updates
Version Tracking
Each state update increments the version counter:
- Initial state has version count 0
- First update increments to version 1
- Subsequent updates continue incrementing
State Types
Dynamic notarizations support both text and binary data:
- Text content: Use
State::from_string()
for textual data - Binary content: Use
State::from_bytes()
for binary data - Metadata: Optional metadata can be included with either type
Timestamps
State updates automatically update the "last state change" timestamp, which can be queried separately from the creation timestamp.
Error Handling
State updates may fail if:
- The notarization is update-locked (locked notarizations cannot be updated)
- Insufficient gas funds
- Invalid state data format
- Network connectivity issues
Full Example Code
- Rust
- Typescript (Node.js)
loading...
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.