Accessing dynamic fields for a shared object in a dApp

I’m looking to migrate to the dynamic fields and dynamic object fields for a few projects, but the inaccessibility of the information about the dynamic fields from a dApp is holding me back. Is there any sense of timing on GitHub Issue #4967

Which I think it the answer to issue #3815

Also correct me if I’m wrong about these being the best ways to handle the retrieval of dynamic field information from a dApp. In my case I’m planning on storing the dynamic fields using a u64 so the retrieval is predictable (e.g. if I know the number of the item to be retrieved I can easily retrieve it).

21 Likes

Hey @Jared-EthosWallet, thanks for posting :smiley:

The dry run work is in-progress, so let me bring this post to the attention of the person that’s working on that. The other option (also in-progress) is new RPC calls to fetch the dynamic fields on a given object. You can see the draft PR for that here:

This should allow you to get a paginated list of an object’s dynamic fields (so would require you to filter it down to the fields you were interested in by their key values after making the request).

If you are interested in fetching a single field value, dryRunMoveCall sounds better, but I just wanted to flag this other option as well.

15 Likes

That sounds great, Either of those RPC calls would be very helpful!

7 Likes

@Jared-EthosWallet
[sui adapter] expose entrypoint for calling `public` function with return values · Issue #5836 · MystenLabs/sui · GitHub is a blocker and when it is done, I will resume the work there and should finish up in a couple of days.

We are still looking to find someone to work on [sui adapter] expose entrypoint for calling `public` function with return values · Issue #5836 · MystenLabs/sui · GitHub so the rough timeline is in the coming a couple of weeks.

Btw we have JSON RPC Docs | Sui Docs and also relaxed it recently to not require signature.

7 Likes

Is there any way to use sui_dryRunTransaction to get access to dynamic fields or dynamic object fields? I can’t think of any way to do that as they don’t show up in the return value for a transaction (as far as I am aware). I assume we’d have to wait for one of the up-and-coming RPC calls such as Replace get_object_owned_by_object with get_dynamic_fields by patrickkuo · Pull Request #5882 · MystenLabs/sui · GitHub

3 Likes

FWIW I didn’t realize that I can call getObjectsOwnedByObject off of the JsonRpcProvider to get access to the dynamic objects stored in a table. I know that function call is being replaced, but in the meantime if others are confused about how to access dynamic objects from a dApp that function currently works.

2 Likes