Is the only purpose of extend_ref
to retrieve object signer?
#3
-
I see we do this pattern a lot when using an object as the owner of an NFT collection. Then later we generate the NFT collection's fun init_module(account: &signer) {
let constructor_ref = object::create_named_object(
account,
OBJECT_SEED,
);
let extend_ref = object::generate_extend_ref(&constructor_ref);
let object_signer = &object::generate_signer(&constructor_ref);
move_to(object_signer, CollectionCapability {
extend_ref,
});
collection::create_unlimited_collection(
object_signer,
description,
name,
option::none(),
uri,
)
}
public entry fun mint_aptogotchi_nft(user: &signer) {
let collection_address = get_collection_address();
let constructor_ref = &token::create(
&get_collection_signer(collection_address),
utf8(APTOGOTCHI_COLLECTION_NAME),
description,
token_name,
option::none(),
uri,
);
let token_signer_ref = &object::generate_signer(constructor_ref);
let aptogotchi = Aptogotchi {
parts,
};
move_to(token_signer_ref, aptogotchi);
} Code pulled from aptogotchi repo. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Sample answer. |
Beta Was this translation helpful? Give feedback.
-
Yes, an extend ref is specifically to generate the object's signer at a later time.
|
Beta Was this translation helpful? Give feedback.
-
What is the purpose of creating a collection using the Object's signer? What is the difference between doing this vs creating a resource account and creating a collection using the resource account's signer? |
Beta Was this translation helpful? Give feedback.
Yes, an extend ref is specifically to generate the object's signer at a later time.
signer
purposely cannot be stored, as it's an authorization object for an address. Instead, anExtendRef
can be stored to generate this signer to eithermove_to
new items, or to authorize operations on an address like such asTokenObjects
. for exampleaptos_token_objects::token::create()