# Sign In/Out

{% tabs %}
{% tab title="EVM" %}
These are the functions you would use in your dApp to interact with Ramper. Import each from @ramper/ethereum

## Sign in

```jsx
const signIn: (clientAPIKey?: string) => Promise<SignInResult>
```

The sign in options such as which SSO providers to allow and which Web3 wallets to allow can be customized through the [`init`](/embedded-wallet-sdk/quickstart/for-web-apps/version-1/sdk-specifications/initialization.md) function. It is recommend to call this function when the user clicks the Sign In Button on your web app.\
\
The clientAPIKey is optional. You can obtain it from Ramper Developer Console (coming soon)

## Sign out

```jsx
const signOut: () => Promise<void>
```

## Response Types

```jsx
type SignInResult = {
  method: 'ramper' | 'wallet' | 'none'
  user?: User
  apiGatingToken?: string
}
```

The `method` value is `'ramper'` if the user logged in using SSO or email and a Ramper managed wallet is created for them. The `method` value is `'wallet'` if the user used a Web3 wallet such as Metamask to log in. Lastly, the method returns `'none'` if the user cancels the log in process.\
\
The `user` value contains information regarding the user that logged in. The `apiGatingToken` is generated based on the `clientAPIKey` if that value was provided on `signIn`. The `apiGatingToken` is an JWT idToken that can be decoded with the `clientAPIKey`. This key can be used to verify that the user has logged in properly.\
\
Example Response:

```jsx
{
   "method":"ramper",
   "user":{
      "signupSource":"google.com",
      "UID":"iskWbvugB0RVsTt70jC7WguEdM02",
      "wallets":{
         "ethereum":{
            "publicKey":"0x2C682335C7E82364790004B8f37F712A18e2b80A",
            "creationDate":1653006881447,
            "walletId":"ethereum_0x2C682335C7E82364790004B8f37F712A18e2b80A",
            "blockchain":"ethereum"
         }
      }
   }
}
```

\
Related Data Types:

```jsx
export type User = {
  wallets: Record<string, Wallet>
} & UserModel

export type UserModel = {
  UID: string
  signupSource: string
  notificationPreference?: string
  email?: string
  preferredCommunicationMethod?: string
  region?: string
}

export type WalletModel = {
  blockchain: string
  walletId: string
  publicKey: string
  creationDate: number // UTC Epoch
  provider?: string
}

export type Wallet = {
  getAddress: () => string
} & WalletModel
```

{% endtab %}

{% tab title="NEAR" %}
These are the functions you would use in your dApp to interact with Ramper. Import each from @ramper/near

## Sign in

```jsx
const signIn: (clientAPIKey?: string) => Promise<SignInResult>
```

The sign in options such as which SSO providers to allow and which Web3 wallets to allow can be customized through the `init` function. It is recommend to call this function when the user clicks the Sign In Button on your web app.\
\
The clientAPIKey is optional. You can obtain it from Ramper Developer Console (coming soon)

## Sign out

```jsx
const signOut: () => Promise<void>
```

## Response Types

```jsx
type SignInResult = {
  method: 'ramper' | 'wallet' | 'cancel' | 'none'
  user?: User
  apiGatingToken?: string
}
```

The `method` value is `'ramper'` if the user logged in using SSO or email and a Ramper managed wallet is created for them. The `method` value is `'wallet'` if the user used a Web3 wallet such as Near Wallet to log in. Lastly, the method returns `'none'` if the user cancels the log in process.\
\
The `user` value contains information regarding the user that logged in. The `apiGatingToken` is generated based on the `clientAPIKey` if that value was provided on `signIn`. The `apiGatingToken` is an JWT idToken that can be decoded with the `clientAPIKey`. This key can be used to verify that the user has logged in properly.\
\
Example Response:

```jsx
{
   "method":"ramper",
   "user":{
      "signupSource":"google.com",
      "UID":"rWoyYQQkzjNZHx8uHKQHuORZ5tD3",
      "wallets":{
         "near":{
            "walletId":"near_51dbd6e5de6a6a89c1054ab5f2dc2adfb47b47b0c1bb766f3346ef42525853ae",
            "creationDate":1654623899156,
            "blockchain":"near",
            "publicKey":"51dbd6e5de6a6a89c1054ab5f2dc2adfb47b47b0c1bb766f3346ef42525853ae"
         }
      }
   },
   "apiGatingToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZXRob2QiOiJyYW1wZXIiLCJVSUQiOiJyV295WVFRa3pqTlpIeDh1SEtRSHVPUlo1dEQzIn0.mSTvGaTKjDtXrVlHjVsJSNdlnEfIFM_6v0mZOJfi-MQ"
}
```

\
Related Data Types:

```jsx
export type User = {
  wallets: Record<string, Wallet>
} & UserModel

export type UserModel = {
  UID: string
  signupSource: string
  notificationPreference?: string
  email?: string
  preferredCommunicationMethod?: string
  region?: string
}

export type WalletModel = {
  blockchain: string
  walletId: string
  publicKey: string
  creationDate: number // UTC Epoch
  provider?: string
}

export type Wallet = {
  getAddress: () => string
} & WalletModel
```

{% endtab %}

{% tab title="Terra" %}
These are the functions you would use in your dApp to interact with Ramper. Import each from @ramper/terra

## Sign in

```jsx
const signIn: (walletToUse?: Wallet, clientAPIKey?: string) => Promise<SignInResult>
```

The sign in options such as which SSO providers to allow and which Web3 wallets to allow can be customized through the `init` function. It is recommend to call this function when the user clicks the Sign In Button on your web app.\
\
The `walletToUse` is the terra wallet provider wallet. The `walletToUse` is required to support Terra Station and WalletConnect. You can obtain the walletToUse with the following code:<br>

```jsx
import { useWallet } from '@terra/wallet-provider'

...

const walletToUse = useWallet()
```

The clientAPIKey is optional. You can obtain it from Ramper Developer Console (coming soon)

## Sign out

```jsx
const signOut: (walletToUse?: Wallet) => Promise<void>
```

## Response Types

```jsx
type SignInResult = {
  method: 'ramper' | 'wallet' | 'none'
  user?: User
  apiGatingToken?: string
}
```

The `method` value is `'ramper'` if the user logged in using SSO or email and a Ramper managed wallet is created for them. The `method` value is `'wallet'` if the user used a Web3 wallet such as Terra Station to log in. Lastly, the method returns `'none'` if the user cancels the log in process.\
\
The `user` value contains information regarding the user that logged in. The `apiGatingToken` is generated based on the `clientAPIKey` if that value was provided on `signIn`. The `apiGatingToken` is an JWT idToken that can be decoded with the `clientAPIKey`. This key can be used to verify that the user has logged in properly.\
\
Example Response:

```jsx
{
   "method":"ramper",
   "user":{
      "signupSource":"google.com",
      "UID":"rWoyYQQkzjNZHx8uHKQHuORZ5tD3",
      "wallets":{
         "terra":{
            "walletId":"terra_terra1yfnuustlzlppr3nhprzqmmadmvx0scx70aj5tk",
            "publicKey":"terra1yfnuustlzlppr3nhprzqmmadmvx0scx70aj5tk",
            "creationDate":1646185360467,
            "blockchain":"terra"
         }
      }
   }
}
```

\
Related Data Types:

```jsx
export type User = {
  wallets: Record<string, Wallet>
} & UserModel

export type UserModel = {
  UID: string
  signupSource: string
  notificationPreference?: string
  email?: string
  preferredCommunicationMethod?: string
  region?: string
}

export type WalletModel = {
  blockchain: string
  walletId: string
  publicKey: string
  creationDate: number // UTC Epoch
  provider?: string
}

export type Wallet = {
  getAddress: () => string
} & WalletModel
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ramper.xyz/embedded-wallet-sdk/quickstart/for-web-apps/version-1/sdk-specifications/sign-in-out.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
