From dfdd7690769a5170236824dfabc1022579e6ad34 Mon Sep 17 00:00:00 2001 From: Greg Nazario Date: Tue, 17 Jun 2025 13:50:50 -0400 Subject: [PATCH] Update digital-asset.mdx Update move syntax to use string::utf8 --- .../build/smart-contracts/digital-asset.mdx | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx b/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx index 4b277d437..53d3e59ac 100644 --- a/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx +++ b/apps/nextra/pages/en/build/smart-contracts/digital-asset.mdx @@ -60,6 +60,7 @@ To make a `Collection` with a fixed supply you can use `collection::create_fixed ```move filename="example.move" use aptos_token_objects::collection; use std::option::{Self, Option}; +use aptos_framework::string; public entry fun create_collection(creator: &signer) { let max_supply = 1000; @@ -68,11 +69,11 @@ public entry fun create_collection(creator: &signer) { // Maximum supply cannot be changed after collection creation collection::create_fixed_collection( creator, - "My Collection Description", + string::utf8(b"My Collection Description"), max_supply, - "My Collection", + string::utf8(b"My Collection"), royalty, - "https://mycollection.com", + string::utf8(b"https://mycollection.com"), ); } ``` @@ -82,16 +83,17 @@ To create a `Collection` with unlimited supply you can use `collection::create_u ```move filename="example.move" use std::option::{Self, Option}; +use aptos_framework::string; public entry fun create_collection(creator: &signer) { let royalty = option::none(); collection::create_unlimited_collection( creator, - "My Collection Description", - "My Collection", + string::utf8(b"My Collection Description"), + string::utf8(b"My Collection"), royalty, - "https://mycollection.com", + string::utf8(b"https://mycollection.com"), ); } ``` @@ -106,15 +108,16 @@ Since each `Collection` is a [Move Object](objects.mdx), you can customize it by ```move filename="example.move" use std::option::{Self, Option}; +use aptos_framework::string; public entry fun create_collection(creator: &signer) { let royalty = option::none(); let collection_constructor_ref = &collection::create_unlimited_collection( creator, - "My Collection Description", - "My Collection", + string::utf8(b"My Collection Description"), + string::utf8(b"My Collection"), royalty, - "https://mycollection.com", + string::utf8(b"https://mycollection.com"), ); let mutator_ref = collection::get_mutator_ref(collection_constructor_ref); // Store the mutator ref somewhere safe @@ -129,6 +132,7 @@ You can further customize your `Collection` by adding more resources or function ```move filename="example.move" use std::option::{Self, Option}; +use aptos_framework::string; struct MyCollectionMetadata has key { creation_timestamp_secs: u64, @@ -139,11 +143,11 @@ public entry fun create_collection(creator: &signer) { // Constructor ref is a non-storable struct returned when creating a new object. // It can generate an object signer to add resources to the collection object. let collection_constructor_ref = &collection::create_unlimited_collection( - creator, - "My Collection Description", - "My Collection", +creator, + string::utf8(b"My Collection Description"), + string::utf8(b"My Collection"), royalty, - "https://mycollection.com", + string::utf8(b"https://mycollection.com"), ); // Constructor ref can be exchanged for signer to add resources to the collection object. let collection_signer = &object::generate_signer(collection_constructor_ref); @@ -194,16 +198,17 @@ You can derive the address for named tokens by: ```move filename="example.move" use aptos_token_objects::token; use std::option::{Self, Option}; +use aptos_framework::string; public entry fun mint_token(creator: &signer) { let royalty = option::none(); token::create( creator, - "Collection Name", - "Description", - "Token Name", + string::utf8(b"Collection Name"), + string::utf8(b"Description"), + string::utf8(b"Token Name"), royalty, - "https://mycollection.com/my-named-token.jpeg", + string::utf8(b"https://mycollection.com/my-named-token.jpeg"), ); } ```