# Wallet Methods

## `login`

Authenticate a user and allocate EOA.

Following arguments can be passed to overwrite the configuration originally set at the instantiation.

### Arguments

<table><thead><tr><th>Parameter</th><th>Type</th><th width="125">Mandatory<select><option value="d1c7a0ea01724bee9cdab675baee4c14" label="Optional" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>authAction</td><td><code>{ login: boolean signup: boolean }</code></td><td><span data-option="d1c7a0ea01724bee9cdab675baee4c14">Optional</span></td><td>Client ID of Auth0 account</td></tr><tr><td>lang</td><td><code>'ja' | 'en'</code></td><td><span data-option="d1c7a0ea01724bee9cdab675baee4c14">Optional</span></td><td>Language displayed on the UI</td></tr><tr><td>loginProvider</td><td><code>['google' | 'email_passwordless' | 'facebook' | 'twitter' | 'line' | 'apple' | 'email_password']</code></td><td><span data-option="d1c7a0ea01724bee9cdab675baee4c14">Optional</span></td><td>Login providers for SSO(Single Sign-On)</td></tr></tbody></table>

### Returns

`Promise<string[] | false>:` An object containing user information.

### Example

```
await startrailSdk().login()
```

{% hint style="danger" %}
Distinct EOAs are assigned for each login provider, regardless of whether the same email is utilized for authentication methods, such as Google and Email Passwordless.

To prevent duplicate registration of accounts with the same email and different EOAs, it is recommended that your application rejects duplicate email registrations on your application side.
{% endhint %}

## `getUserInfo`

Get the logging-in user information.

### Returns

`Promise<UserInfo | false>:` The promise resolves upon the request success and rejects with a specific error code if the request fails.

| Value        | Type                                                                                                   | Description                                                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| email        | `string`                                                                                               | <p>If selected social login allows email sharing.<br>See more details in<a data-mention href="login-providers">login-providers</a></p> |
| name         | `string`                                                                                               | If selected social login knows your name                                                                                               |
| profileImage | `string`                                                                                               | If selected social login knows your profile image                                                                                      |
| typeOfLogin  | `'google' \| 'email_passwordless' \| 'facebook' \| 'twitter' \| 'line' \| 'apple' \| 'email_password'` | Selected social login type                                                                                                             |
| wallet       | `'startrail' \| 'metamask'`                                                                            | Selected wallet type                                                                                                                   |
| verifier     | `string`                                                                                               | <p>Web3Auth only feature.<br>It determines your EOA.</p>                                                                               |
| verifierId   | `string`                                                                                               | <p>Web3Auth only feature.<br>Verifier Id of the logged in user if your selected wallets knows it</p>                                   |
| isNewUser    | `boolean`                                                                                              | <p>Web3Auth only feature.<br>Returns if the logged in user is new to Torus wallet which supports Startrail login</p>                   |

{% hint style="info" %}

```
Verifier is an identifier that determines EOA in Web3Auth network.
It is only returned under Web3Auth service.
```

{% endhint %}

See more details for the [login-providers](https://docs.startrail.io/startrail-sdk-js/login-providers "mention")

### Example

```
await startrailSdk().getUserInfo()
// Response example
// Google Login
{
  email: "sample@example.jp"
  name: "your Google account name"
  profileImage: "https://lh3.googleusercontent.com/a/image_on_google_account"
  typeOfLogin: "google"
  verifier: "google"
  verifierId: "sample@example.jp",
  wallet: "startrail",
  isNewUser: false // Returns if the logged in user is new to Torus wallet
}
// Email&Passwordless
{ 
  email: "sample@example.jp"
  name: "sample@example.jp"
  profileImage: "https://s.gravatar.com/avatar/image_of_default_auth0_icon.png"
  typeOfLogin: "email_passwordless"
  verifier: "torus-auth0-email-passwordless"
  verifierId: "sample@example.jp",
  wallet: "startrail",
  isNewUser: false // Returns if the logged in user is new to Torus wallet
}
```

## `signMessage`

Sign message with the Ethereum private key associated to your wallet

### `Arguments`

<table><thead><tr><th>Parameter</th><th>Type</th><th>Mandatory<select><option value="b9c67093cab14267a1884ca9333c6c79" label="Optional" color="blue"></option><option value="d9ccd44962294e47b0a04768cbea0fa3" label="Required" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>message</td><td><code>string</code></td><td><span data-option="d9ccd44962294e47b0a04768cbea0fa3">Required</span></td><td>A message to be signed</td></tr><tr><td>disableCustomPrefix</td><td><code>string</code></td><td><span data-option="b9c67093cab14267a1884ca9333c6c79">Optional</span></td><td>Web3Auth only feature to skip singing popup.<br>See more <a href="login-providers/startrail-powered-by-web3auth-torus">details here</a></td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>

### Returns

`Promise<{signature: string, prefix: string | false} | false>:`

### Example

```
await startrailSdk().signMessage('sample')
```

## `switchLanguage`

Switch language for Web3Auth wallet UI

### `Arguments`

<table><thead><tr><th>Parameter</th><th>Type</th><th>Mandatory<select><option value="b9c67093cab14267a1884ca9333c6c79" label="Optional" color="blue"></option><option value="d9ccd44962294e47b0a04768cbea0fa3" label="Required" color="blue"></option></select></th><th>Description</th></tr></thead><tbody><tr><td>lang</td><td><code>"ja" | "en"</code></td><td><span data-option="d9ccd44962294e47b0a04768cbea0fa3">Required</span></td><td>Web3Auth only feature to switch language</td></tr></tbody></table>

### Returns

`Promise<void | false>`

### Example

```
await startrailSdk().switchLanguage("ja")
```

## `logout`

Logout from the wallet.

### Returns

`Promise<void | false>` The promise resolves upon logout request success and rejects with a specific error code if the request fails.

### Example

```
await startrailSdk().logout()
```

{% hint style="info" %}

#### About Page reload and data persistency <a href="#ac1043f5-f618-4c0d-9782-d7c34b7a1b0f" id="ac1043f5-f618-4c0d-9782-d7c34b7a1b0f"></a>

* Wallet information is stored in browser session storage under Torus service domain.
* As SDK instance is gone at page reload, it's no longer available unless it is instantiated again. User, however, does not require additional login process to trigger its function call since the session between Torus node and Authenticator keeps maintained until sdk.logout function is called
  {% endhint %}
