# Accessing dynamic fields for a shared object in a dApp

**URL:** <https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64>\
**Category:** General\
**Created:** [November 9, 2022, 12:00pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64 "2022-11-09T12:00:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jared-EthosWallet](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/jared-ethoswallet/32/20_2.png) [@Jared-EthosWallet](https://forums.sui.io/u/Jared-EthosWallet)\
**Post date:** [November 9, 2022, 12:00pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/1 "2022-11-09T12:00:08Z")

</div>

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

> <https://github.com/MystenLabs/sui/issues/4967>
>
> We currently have \`dryRunTransaction\` which takes a complete transaction and sim…ulates it without committing it. For Wallets and Explorers, we also need a \`dryRunMoveCall\`. This shouldn't require a complete valid transaction like \`dryRunTransaction\` does.
> 
> \- Should not require a signed transaction.
> \- Should not validate owned objects.
> \- Should not require a gas object.
> 
> As an example use-case for explorer, we want users to be able to inspect the result of function calls on published packages (essentially treating them as a \`view\` function).

Which I think it the answer to issue #3815

> <https://github.com/MystenLabs/sui/issues/3815>
>
> This is useful for exposing the results of on-chain logic implemented in Move (e….g., price calculations), or just generally executing code without needing a local VM.
> 
> Basically, this is equivalent of \`view\` functions in Eth. But because Sui Move is pure, we don't (I think) have to worry about view functions that can be called in this way and non-view functions that cannot--everything is basically a view function. We could consider not allowing invocation of functions that do transfers and emit events, but it is harmless to support this if we want to...
> 
> More context in Discord: https://discord.com/channels/916379725201563759/925108748551323649/1005595327291731989

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).

---

<div class="post-metadata">

**Author:** ![amnn](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/amnn/32/25_2.png) [@amnn](https://forums.sui.io/u/amnn)\
**Post date:** [November 9, 2022, 12:09pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/2 "2022-11-09T12:09:38Z")

</div>

Hey @Jared-EthosWallet, thanks for posting 😃

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:

> <https://github.com/MystenLabs/sui/pull/5882>
>
> \* added \`dynamic\_field\_index\` to \`AuthorityPerpetualTables\` storing all object o…wned dynamic field objects
> \* owner\_index now only stores address owned object
> 
> \## Examples:
> the first object is \`nfts::geniteam::Player\`, second object is \`nfts::marketplace::Marketplace\`
> Requests
> \`\`\`
> curl --location --request POST '127.0.0.1:9000' \\
> \--header 'Content-Type: application/json' \\
> \--data-raw '\[{
> "jsonrpc": "2.0",
> "id": 1,
> "method": "sui\_getDynamicFields",
> "params": \[
> "0x915c8c04455680f3eda8530b4145f8acb35f855e"
> \]
> },{
> "jsonrpc": "2.0",
> "id": 1,
> "method": "sui\_getDynamicFields",
> "params": \[
> "0x4b66e8547e356b35b212ea7786f6f870125aaab8"
> \]
> }\]
> \`\`\`
> Response
> \`\`\`
> \[
> {
> "jsonrpc": "2.0",
> "result": {
> "data": \[
> {
> "name": "0xdc7c24a5f621a3b916501baeec3d00b9f183fba2",
> "type": "Object",
> "objectType": "0xcd849157708c15379e4ad36dfc2f2c805bed8593::geniteam::Farm",
> "objectId": "0xdc7c24a5f621a3b916501baeec3d00b9f183fba2",
> "version": 1,
> "digest": "yH333h2MTgI7wlxp022uZB1G5XstKvGyUvxjrdGwxBQ="
> }
> \],
> "nextCursor": null
> },
> "id": 1
> },
> {
> "jsonrpc": "2.0",
> "result": {
> "data": \[
> {
> "name":"0xc6b225ff5942b7c46f16e6e8914fb01d44797d75"
> "type": {
> "Field": "0x900ba8cbe034f888f2f8ea4d5bfff712dd219bd4"
> },
> "objectType": "0x215ac130a803828900ee5daabf63a1dc0f6414d9::marketplace::Listing\<0x2::devnet\_nft::DevNetNFT, 0x2::sui::SUI\>",
> "objectId": "0xc6b225ff5942b7c46f16e6e8914fb01d44797d75",
> "version": 1,
> "digest": "gwJoTfWz4GtMgMxucQN8l/jGuvvzydOaMiDLwEPLtxM="
> }
> \],
> "nextCursor": null
> },
> "id": 2
> }
> \]
> \`\`\`
> 
> 
> TODOs:
> \- \[\] refactor \`get\_object\_owned\_by\_address\` and add pagination support
> \- \[\] Testing
> \- \[\] Docs

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.

---

<div class="post-metadata">

**Author:** ![Jared-EthosWallet](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/jared-ethoswallet/32/20_2.png) [@Jared-EthosWallet](https://forums.sui.io/u/Jared-EthosWallet)\
**Post date:** [November 9, 2022, 12:26pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/3 "2022-11-09T12:26:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ggaowp](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/ggaowp/32/26_2.png) [@ggaowp](https://forums.sui.io/u/ggaowp)\
**Post date:** [November 9, 2022, 4:45pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/4 "2022-11-09T16:45:53Z")

</div>

@Jared-EthosWallet  
[[sui adapter] expose entrypoint for calling `public` function with return values · Issue #5836 · MystenLabs/sui · GitHub](https://github.com/MystenLabs/sui/issues/5836) 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](https://github.com/MystenLabs/sui/issues/5836) so the rough timeline is in the coming a couple of weeks.

Btw we have [JSON RPC Docs | Sui Docs](https://docs.sui.io/sui-jsonrpc#sui_dryRunTransaction) and also relaxed it recently to not require signature.

---

<div class="post-metadata">

**Author:** ![Jared-EthosWallet](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/jared-ethoswallet/32/20_2.png) [@Jared-EthosWallet](https://forums.sui.io/u/Jared-EthosWallet)\
**Post date:** [November 18, 2022, 1:44pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/5 "2022-11-18T13:44:03Z")

</div>

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](https://github.com/MystenLabs/sui/pull/5882)

---

<div class="post-metadata">

**Author:** ![Jared-EthosWallet](https://dub1.discourse-cdn.com/sui/user_avatar/forums.sui.io/jared-ethoswallet/32/20_2.png) [@Jared-EthosWallet](https://forums.sui.io/u/Jared-EthosWallet)\
**Post date:** [November 30, 2022, 3:56pm UTC](https://forums.sui.io/t/accessing-dynamic-fields-for-a-shared-object-in-a-dapp/64/6 "2022-11-30T15:56:33Z")

</div>

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.
