Before you write a helper
The JavaScript SDK,@stellar/stellar-sdk, has built-in helpers for many tasks that apps often code by hand. Check this table before you write your own. Every helper here is in version 17.x of the SDK, and each name links to its entry in the SDK reference.
The call forms below use these imports and an RPC client for testnet: