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

# Actions SDK 설정하기

> 애플리케이션에 맞게 Actions SDK를 설정하는 방법을 알아봅니다.

Actions SDK를 사용하면 설정 파일을 통해 애플리케이션에서 지원할 자산, 마켓, 체인, 프로토콜, 제공업체를 선택할 수 있습니다.

**1. Actions SDK 설치**

[빠른 시작](https://docs.optimism.io/ko/app-developers/quickstarts/actions.md) 가이드를
따라 앱에 Actions SDK를 의존성으로
추가합니다.

**2. 임베디드 지갑 통합**

[Actions SDK에 지갑
연결하기](https://docs.optimism.io/ko/app-developers/guides/connect-wallet-to-actions.md) 가이드를 따라
Wallet Provider를 선택하고 설치합니다.

**3. 설정 파일 생성**

`actions.ts` - 모든 설정 기본값을 담는 접근 가능한 파일입니다.

**4. Wallet Provider 설정**

선택한 Wallet Provider를 Actions SDK에 알려 줍니다.

> [tab] 프런트엔드
>
> 지갑 제공업체를 선택합니다.
>
> > [tab] Privy
> >
> > ```typescript title="actions.ts" theme={null}
> > const walletConfig = {
> >   hostedWalletConfig: {
> >     provider: {
> >       type: "privy" as const,
> >     },
> >   },
> >   smartWalletConfig: {
> >     provider: {
> >       type: "default" as const,
> >       attributionSuffix: "actions",
> >     },
> >   },
> > };
> > ```
>
> > [tab] Turnkey
> >
> > ```typescript title="actions.ts" theme={null}
> > const walletConfig = {
> >   hostedWalletConfig: {
> >     provider: {
> >       type: "turnkey" as const,
> >     },
> >   },
> >   smartWalletConfig: {
> >     provider: {
> >       type: "default" as const,
> >       attributionSuffix: "actions",
> >     },
> >   },
> > };
> > ```
>
> > [tab] Dynamic
> >
> > ```typescript title="actions.ts" theme={null}
> > const walletConfig = {
> >   hostedWalletConfig: {
> >     provider: {
> >       type: "dynamic" as const,
> >     },
> >   },
> >   smartWalletConfig: {
> >     provider: {
> >       type: "default" as const,
> >       attributionSuffix: "actions",
> >     },
> >   },
> > };
> > ```

> [tab] 백엔드
>
> 지갑 제공업체를 선택합니다.
>
> > [tab] Privy
> >
> > ```typescript title="actions.ts" theme={null}
> > import { PrivyClient } from '@privy-io/node'
> >
> > const privyClient = new PrivyClient(
> >   process.env.PRIVY_APP_ID,
> >   process.env.PRIVY_APP_SECRET,
> > )
> >
> > const walletConfig = {
> >   hostedWalletConfig: {
> >     provider: {
> >       type: "privy" as const,
> >       config: {
> >         privyClient,
> >       },
> >     },
> >   },
> >   smartWalletConfig: {
> >     provider: {
> >       type: "default" as const,
> >       attributionSuffix: "actions",
> >     },
> >   },
> > };
> > ```
>
> > [tab] Turnkey
> >
> > ```typescript title="actions.ts" theme={null}
> > import { Turnkey } from '@turnkey/sdk-server'
> >
> > const turnkeyClient = new Turnkey({
> >   apiBaseUrl: 'https://api.turnkey.com',
> >   apiPublicKey: process.env.TURNKEY_API_KEY,
> >   apiPrivateKey: process.env.TURNKEY_API_SECRET,
> >   defaultOrganizationId: process.env.TURNKEY_ORGANIZATION_ID,
> > })
> >
> > const walletConfig = {
> >   hostedWalletConfig: {
> >     provider: {
> >       type: "turnkey" as const,
> >       config: {
> >         client: turnkeyClient.apiClient(),
> >       },
> >     },
> >   },
> >   smartWalletConfig: {
> >     provider: {
> >       type: "default" as const,
> >       attributionSuffix: "actions",
> >     },
> >   },
> > };
> > ```

**5. 지원 자산 설정**

모든 lend 제공업체에서 지원할 자산을 설정합니다.

```typescript title="actions.ts" theme={null}
// Additional config from previous steps...

// Import popular assets
import { USDC } from '@eth-optimism/actions-sdk/assets'
import type { Asset, AssetsConfig } from "@eth-optimism/actions-sdk";

// Or define custom assets
export const CustomToken: Asset = {
  address: {
    [mainnet.id]: '0x123...',
    [unichain.id]: '0x456...',
    [baseSepolia.id]: '0x789...',
  },
  metadata: {
    decimals: 6,
    name: 'Custom Token',
    symbol: 'CUSTOM',
  },
  type: 'erc20',
}

// Configure allowed/blocked assets
const assetsConfig: AssetsConfig = {
  allow: [USDC, CustomToken],
  block: [],  // Optional
}
```

**6. 마켓 설정**

앱에서 지원하거나 차단할 마켓을 정의합니다.

```typescript title="actions.ts" theme={null}
// Additional config from previous steps...

export const GauntletUSDC: LendMarketConfig = {
  address: '0xabc...',
  chainId: unichain.id,
  name: 'Gauntlet USDC',
  asset: USDC,
  lendProvider: 'morpho',
}
```

**7. Lend 제공업체 설정**

지원할 lend 프로토콜을 설정합니다. 하나 또는 여러 제공업체를 활성화할 수 있습니다.

```typescript title="actions.ts" theme={null}
// Additional config from previous steps...

import type { LendConfig } from "@eth-optimism/actions-sdk";

const lendConfig: LendConfig = {
  morpho: {
    marketAllowlist: [GauntletUSDC],
    marketBlocklist: [],  // Optional
  },
  aave: {
    marketAllowlist: [AaveWETH],
    marketBlocklist: [],  // Optional
  },
};
```

**8. 지원 체인 설정**

지원할 체인을 설정합니다.

```typescript title="actions.ts" theme={null}
// Additional config from previous steps...

import { optimism, base } from "viem/chains";

// Define any EVM chain
const OPTIMISM = {
  chainId: optimism.id,
  rpcUrls: env.OPTIMISM_RPC_URL,
  bundler: {
    // Bundle and sponsor txs with a gas paymaster
    type: "simple" as const,
    url: env.OPTIMISM_BUNDLER_URL,
  },
};

const BASE = {
  chainId: base.id,
  rpcUrls: env.BASE_RPC_URL,
  bundler: {
    // Bundle and sponsor txs with a gas paymaster
    type: "simple" as const,
    url: env.BASE_BUNDLER_URL,
  },
};

const chains = [OPTIMISM, BASE];
```

**9. Actions 초기화**

마지막으로 모든 설정을 하나로 모아 Actions를 초기화합니다.

```typescript title="actions.ts" theme={null}
// Additional config from previous steps...

export const actions = createActions({
  wallet: walletConfig,
  assets: assetsConfig,
  lend: lendConfig,
  chains,
});
```

**10. 작업 실행**

actions 인스턴스를 초기화한 후에는 작업을 실행해야 하는 곳 어디에서든 import하여 사용할 수 있습니다.

```typescript theme={null}
import { actions } from './actions';

// Use actions anywhere in your app
const market = await actions.lend.getMarket({ ... });
const wallet = await actions.wallet.createSmartWallet({ ... });
const receipt = await wallet.lend.openPosition({ ... });
```

## 다음 단계

자세한 API 문서와 타입 정의는 [Actions SDK 레퍼런스](https://docs.optimism.io/ko/app-developers/reference/actions/integrating-wallets.md)를 참고하십시오.
