github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/reference/tm2-js-client/Provider/utility.md (about) 1 --- 2 id: tm2-js-utility 3 --- 4 5 # Utility Helpers 6 7 ## Provider Helpers 8 9 ### extractBalanceFromResponse 10 11 Extracts the specific balance denomination from the ABCI response 12 13 #### Parameters 14 15 * `abciData` **(string | null)** the base64-encoded ABCI data 16 * `denomination` **string** the required denomination 17 18 ### extractSequenceFromResponse 19 20 Extracts the account sequence from the ABCI response 21 22 #### Parameters 23 24 * `abciData` **(string | null)** the base64-encoded ABCI data 25 26 Returns **number** 27 28 ### extractAccountNumberFromResponse 29 30 Extracts the account number from the ABCI response 31 32 #### Parameters 33 34 * `abciData` **(string | null)** the base64-encoded ABCI data 35 36 Returns **number** 37 38 ### waitForTransaction 39 40 Waits for the transaction to be committed to a block in the chain 41 of the specified provider. This helper does a search for incoming blocks 42 and checks if a transaction 43 44 #### Parameters 45 46 * `provider` **Provider** the provider instance 47 * `hash` **string** the base64-encoded hash of the transaction 48 * `fromHeight` **number** the starting height for the search. If omitted, it is the latest block in the chain ( 49 optional, default `latest`) 50 * `timeout` **number** the timeout in MS for the search (optional, default `15000`) 51 52 Returns **Promise<Tx\>** 53 54 ## Request Helpers 55 56 ### newRequest 57 58 Creates a new JSON-RPC 2.0 request 59 60 #### Parameters 61 62 * `method` **string** the requested method 63 * `params` **Array<string\>?** the requested params, if any 64 65 Returns **RPCRequest** 66 67 ### newResponse 68 69 Creates a new JSON-RPC 2.0 response 70 71 #### Parameters 72 73 * `result` **Result** the response result, if any 74 * `error` **RPCError** the response error, if any 75 76 Returns **RPCResponse<Result\>** 77 78 ### parseABCI 79 80 Parses the base64 encoded ABCI JSON into a concrete type 81 82 #### Parameters 83 84 * `data` **string** the base64-encoded JSON 85 86 Returns **Result** 87 88 ### stringToBase64 89 90 Converts a string into base64 representation 91 92 #### Parameters 93 94 * `str` **string** the raw string 95 96 Returns **string** 97 98 ### base64ToUint8Array 99 100 Converts a base64 string into a Uint8Array representation 101 102 #### Parameters 103 104 * `str` **string** the base64-encoded string 105 106 Returns **Uint8Array** 107 108 ### uint8ArrayToBase64 109 110 Converts a Uint8Array into base64 representation 111 112 #### Parameters 113 114 * `data` **Uint8Array** the Uint8Array to be encoded 115 116 Returns **string**