Skip to content

XDR to JS Numbers and String Conversion

Piyal Basu edited this page Jun 22, 2023 · 3 revisions

Parsing an XDR to display the results as Javascript.

A common use case is calling simulateTransaction to get a read-only property of a contract. simulateTransaction returns an XDR that needs to be parsed in order to display in a UI. For ex: [token balance] (https://github.com/stellar/soroban-react-payment/blob/main/src/helpers/soroban.ts#L318):

Converting an i128 from an XDR to String: helper method

Convert an u32 from an XDR to Number: helper method

Convert Bytes from an XDR to String: helper method

Convert Account from an XDR to String: helper method

Clone this wiki locally