> ## Documentation Index
> Fetch the complete documentation index at: https://docs.garden.finance/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

**1. Prerequistes**

This guide assumes that you have completed the [Setup](https://docs.garden.finance/docs/developers/sdk/nodejs/setup.md) guide.

**2. Initialize wallets and providers**

> [!TIP]
>
> Initialize wallets and providers only for the chains you need.

```ts theme={null}
import {
    BitcoinProvider,
    BitcoinNetwork,
    BitcoinWallet,
} from '@gardenfi/core';
import { with0x } from '@gardenfi/utils';
import { createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { arbitrumSepolia } from 'viem/chains';
import { RpcProvider, Account } from 'starknet';
import * as anchor from '@coral-xyz/anchor';
import { web3 } from '@coral-xyz/anchor';

// Ethereum wallet setup
const ethereumAccount = privateKeyToAccount(with0x('<YOUR_EVM_PRIVATE_KEY>'));
const ethereumWalletClient = createWalletClient({
    account: ethereumAccount,
    chain: arbitrumSepolia,
    transport: http(),
});

// Starknet wallet setup
const starknetProvider = new RpcProvider(); // Using default RPC URL
const starknetWallet = new Account({
    provider: starknetProvider,
    signer: <YOUR_STARKNET_PRIVATE_KEY>,
    address: <YOUR_STARKNET_ADDRESS>,
});

// Solana wallet setup
const solanaPrivKeyBytes = new Uint8Array('<YOUR_SOLANA_PRIVATE_KEY_IN_BYTES>');
const solanaUser = web3.Keypair.fromSecretKey(solanaPrivKeyBytes);
const solanaConnection = new web3.Connection(RPC_URL, { commitment: 'confirmed' });
const solanaWallet = new anchor.Wallet(solanaUser);
const solanaProvider = new anchor.AnchorProvider(solanaConnection, solanaWallet);
```

**3. Configure Garden instance**

> [!TIP]
>
> For API key, reach out to us in the [Townhall](https://discord.gg/B7RczEFuJ5) or raise a support ticket.

> [tab] Default wallet clients
>
> ```js theme={null}
> import { Garden } from '@gardenfi/core';
> import { Network } from '@gardenfi/utils';
>
> const garden = Garden.fromWallets({
>     environment: Network.TESTNET,
>     apiKey: '<YOUR_API_KEY>',
>     wallets: {
>         evm: ethereumWalletClient,
>         starknet: starknetWallet,
>         solana: solanaProvider
>     }
> });
> ```

> [tab] Custom client configuration
>
> > [!NOTE]
> >
> > You can initialize the Garden instance with your own HTLC client implementations. Check out the [IEVMHTLC](https://github.com/gardenfi/garden.js/blob/main/packages/core/src/lib/evm/htlc.types.ts), [IStarknetHTLC](https://github.com/gardenfi/garden.js/blob/main/packages/core/src/lib/starknet/starknetHTLC.types.ts), and [ISolanaHTLC](https://github.com/gardenfi/garden.js/blob/main/packages/core/src/lib/solana/htlc/ISolanaHTLC.ts) interfaces for more details.
>
> ```js theme={null}
> import { Garden } from '@gardenfi/core';
> import { Network } from '@gardenfi/utils';
>
> const garden = new Garden({
>     environment: Network.TESTNET,
>     apiKey: '<YOUR_API_KEY>',
>     htlc: {
>         evm: <IEVMHTLC>,
>         starknet: <IStarknetHTLC>,
>         solana: <ISolanaHTLC>
>     },
> });
> ```

**4. Create a swap**

```js theme={null}
import { Quote, SwapParams } from '@gardenfi/core';
import { Assets, ChainAsset } from '@gardenfi/orderbook';

const fromAsset = ChainAsset.from(Assets.ethereum_sepolia.WBTC);
const toAsset = ChainAsset.from(Assets.bitcoin_testnet.BTC);

const sendAmount = '1000000'; // 0.01 WBTC

// Get the quote for the send amount
const quote = await garden.quote.getQuote(
    fromAsset,
    toAsset,
    sendAmount,
    false,
    {},
);

const receiveAmount = quote.val?.[0].destination.amount;
const solverId = quote.val?.[0].solver_id;
const sourceAddress = ethereumAccount.address;
const destinationAddress = '<YOUR_BITCOIN_ADDRESS';

const swapParams: SwapParams = {
    fromAsset,
    toAsset,
    sendAmount,
    receiveAmount,
    solverId,
    sourceAddress,
    destinationAddress
};

// Create the swap
const swapResult = await garden.createSwap(swapParams);

if (!swapResult.ok) {
    throw new Error(swapResult.error);
}

console.log('Order created and initiated ✅', swapResult.val);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.