Skip to content

Decoding custom smart contract types in dApp/front-end with SDK v13 โ€“ missing or outdated exampleย #1095

@eduardoPauloPanstein

Description

@eduardoPauloPanstein

Hey team,

I'm working on a real-world use case and wanted to share a gap I found in the current documentation, especially for developers following the recommended dApp setup.


๐Ÿ” Summary of the Problem

  1. I learned how to create smart contracts and successfully deployed a custom one on the devnet. Everything worked smoothly up to this point.
  2. To build a frontend for users to interact with the contract, I followed the usual path โ€” using the template-dapp as recommended (it includes the ping-pong examples).
  3. I removed the ping-pong logic and adapted it to my contract, which returns a custom type that I need to decode.
  4. For that, I referred to the v13 SDK JS cookbook to follow best practices and avoid using the now outdated SmartContract.createQuery() method (still present in the template-dapp).
  5. However, I hit some issues right away:
    • The code sample in the cookbook uses apiNetworkProvider, which isnโ€™t defined in the template-dapp context.
    • After digging, I found it is defined earlier in the cookbook, but that setup isnโ€™t compatible with the template-dapp structure. I had to reverse-engineer how to plug it in correctly.
  6. Once I got past that, I reached the main blocker: the example for decoding a custom type simply does not work. I tried both getCustomType() and getStruct() with no success, and couldnโ€™t find a working example that bridges the gap between template-dapp and decoding with ABI in the frontend. Even after reading through SDK v14 resources and cross-checking with older tutorials, I couldn't get the decoding to work from the frontend as documented. I eventually made it work another way โ€” but it took hours of trial and error.

โ— Why This Matters

This flow is the first thing new developers will try when building on MultiversX with custom logic. The experience should be smooth โ€” especially when the recommended template and cookbooks don't align anymore.


๐Ÿ“Œ Priority

Medium-High โ€” This blocks progress for developers building real apps with custom return types.


๐Ÿ™Œ Offer to Help

Happy to:

  • Share my repo with a working version
  • Provide code snippets
  • Record a short video (~4 minutes) showing exactly where the friction
  • Or even jump on a call

Letโ€™s improve this together! ๐Ÿš€


Tags: documentation, sdk-js, v13, v14, abi, custom-types, frontend, template-dapp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions