Post
Share your knowledge.
Accessing Dynamic Child Objects in Parent Objects: Alternative Move Module Methods
I've created a child object using a dynamic object field, resulting in the creation of a new object with a dynamic type that stores the child. However, I'm having trouble viewing the information of the dynamic object within the parent object. I attempted to use a bag to collect the data, but I still can't access the child object's information from the parent object. Is there an alternative method to view the details of the child object if I only have access to the parent object?
- Move
Answers
2If you need to access a child object on-chain, you must have access to the parent object and know the field name. On the other hand, if you are operating off-chain, you can leverage the suix_getDynamicFieldObject
API to achieve the same functionality. Here are the details for both options:
- Accessing Child Object On-Chain: You need access to the parent object. You must know the specific field name where the child object is stored.
- Accessing Child Object Off-Chain: Utilize the
suix_getDynamicFieldObject
API. This API allows you to retrieve the child object associated with a specific field within the parent object. You can find more information about this API in the SUI JSON RPC documentation. Additionally, you can use thesuix_getDynamicFields
API to list all the dynamic fields of a parent object. This API provides you with an overview of the available dynamic fields in the parent object. More details can be found in the Sui JSON RPC documentation. Please note that the documentation reference you provided regarding objects being hidden from external storage specifically applies to dynamic fields added usingsui::dynamic_field::add
. This limitation does not apply to dynamic object fields added usingsui::dynamic_object_fields::add
as demonstrated in your example. If you add an object as a dynamic object field, you can access it without any issues, both on-chain and off-chain.
The Sui framework provides a way to create child objects and add them as dynamic fields using the transfer_to_object
function. This function allows an object to be transferred to another object, making it a child object of the parent object. The parent object then stores the ID of the child object in a dynamic field. This is described in github.com and docs.sui.io.
To access the details of the child object from the parent object, you would need to retrieve the ID of the child object from the parent object's dynamic field. You can then use this ID to query the Sui blockchain and retrieve the details of the child object. Here's a step-by-step guide on how you might approach this:
- Retrieve the ID of the child object: You can do this by accessing the dynamic field of the parent object that stores the ID of the child object.
- Query the Sui blockchain: Once you have the ID of the child object, you can query the Sui blockchain to retrieve the details of the child object. This can be done using the
getOwnedObjects
RPC method, as described in docs.sui.io. - Process the retrieved data: After retrieving the details of the child object, you can process this data as needed. Please note that these are general suggestions and may not be applicable or feasible in the specific context of the Sui framework. For a more accurate and specific solution, it would be best to consult the Sui documentation or seek advice from the Sui community.
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.

- ... SUIderiss+5
- ... SUIRamirez+5
- ... SUIElvin CLONE +5
- ... SUI
- ... SUI
- ... SUI
- ... SUIBritain+2