Getting Started With Sui and TypeScript
The only prerequisite is that you’ll need basic JS/TS knowledge to run this tutorial smoothly. I’ll walk you through everything else. First, create a new TypeScript project in your terminal and initialize a new Node.js project.[Terminal]
[Terminal]
tsconfig.json
file with default options that you can customize for your project.
[Terminal]
tsconfig.json
and paste these configurations.
[tsconfig.json]
src
directory where you’ll add your TypeScript files.
[Terminal]
[Terminal]
Connecting to the Sui Blockchain
You must connect to a Sui blockchain to interact with the chain. First, importgetFullnodeUrl
and SuiClient
from the SDK client module.
[Terminal]
getFullnodeUrl
to retrieve the full node URL of the Sui testnet, mainnet, localnet, or devnet; then, use the SuiClient
to connect to the client instance.
[index.ts]
getLatestSuiSystemState
to retrieve the latest state of the network.
[index.ts]
[Terminal]

Creating a Sui Wallet
Creating a wallet is another popular operation that might be handy if you build on the Sui Network. Here’s how to generate Sui wallet keypairs and retrieve the private and public keys from the Keypair.[index.ts]
Ed25519Keypair
function creates a new key pair. The getPublicKey
and getPrivateKey
methods give you access to the public and private keys, respectively.
Here’s the string output of the private and public keys I generated with the program:
Reading Sui Wallet Balances
You can use thegetCoins
function on your client instance to retrieve details on the coins in a wallet address.
[index.ts]

[index.ts]

Send Coins or Objects
Finally, the interesting part is that you’ll learn to send transactions on the blockchain. Let’s send some $FUD tokens to another wallet. This works for any coins on the Sui Network.[index.ts]
tx.transferObjects
transfer the split coin to the specified address.
Finally, you need to sign the transaction with the client.signAndExecuteTransaction
, and you can wait for the transaction with waitForTransaction
to confirm the transaction went through