Skip to main content

Network Environments


Connecting to specific network environment

When you are working on Sui development, you will need to connect to a specific Sui Full node on a Sui network.

TypeScript
import { SuiClient, getFullnodeUrl } from '@mysten/sui.js/client';

// create a client object connected to localnet
const client = new SuiClient({ url: getFullnodeUrl('localnet') });

Getting Test Sui

If you want to test transactions on Sui network you need first to get Sui coins in your wallet. To receive test Sui in your wallet you have to make a request to the faucet server.

TypeScript
import { JsonRpcProvider, devnetConnection } from "@mysten/sui.js";

// connect to Devnet
const provider = new JsonRpcProvider(devnetConnection);

// get test Sui from the DevNet faucet server
await provider.requestSuiFromFaucet(
  "0x8bab471b0b2e69ac5051c58bbbf81159c4c9d42bf7a58d4f795ecfb12c968506"
);