S
S
Startrail APIs
Ask or search…
K
Comment on page
💳

Wallet Methods

To know Web3 wallet relevant methods in Startrail-Sdk-Js

login

Authenticate a user and allocate EOA.
Following arguments can be passed to overwrite the configuration originally set at the instantiation.

Arguments

Parameter
Type
Mandatory
Description
authAction
{ login: boolean signup: boolean }
Optional
Client ID of Auth0 account
lang
'ja' | 'en'
Optional
Language displayed on the UI
loginProvider
['google' | 'email_password' | 'facebook' | 'twitter' | 'line' | 'apple' | 'email_passwordless']
Optional
Login providers for SSO(Single Sign-On)

Returns

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

Example

await startrailSdk().login()
Google Auth Email&Password EOA is not the same.
Different EOA is allocated even if the same email is used for Google and Email&Password authentication.
If duplicate registration of the account with the same email and different EOA should be avoided, it is recommend that your application rejects duplicate email registration on your application side.

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
If selected social login allows email sharing
name
string
If selected social login knows your name
profileImage
string
If selected social login knows your profile image
typeOfLogin
'google' | 'email_password' | 'facebook' | 'twitter' | 'line' | 'apple' | 'email_passwordless'
Selected social login type
wallet
'startrail' | 'metamask'
Selected wallet type
verifier
string
Web3Auth only feature. It determines your EOA.
verifierId
string
Web3Auth only feature. Verifier Id of the logged in user if your selected wallets knows it
isNewUser
boolean
Web3Auth only feature. Returns if the logged in user is new to Torus wallet which supports Startrail login
Verifier is an identifier that determines EOA in Web3Auth network.
It is only returned under Web3Auth service.
See more details of verifier: Login Providers

Example

await startrailSdk().getUserInfo()
// Response example
// Google Login
{
name: "your Google account name"
profileImage: "https://lh3.googleusercontent.com/a/image_on_google_account"
typeOfLogin: "google"
verifier: "google"
verifierId: "[email protected]",
wallet: "startrail",
isNewUser: false // Returns if the logged in user is new to Torus wallet
}
// Email&Passwordログイン時
{
profileImage: "https://s.gravatar.com/avatar/image_of_default_auth0_icon.png"
typeOfLogin: "email_password"
verifier: "startrail-auth0-staging"
verifierId: "[email protected]",
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

Parameter
Type
Mandatory
Description
message
string
Required
A message to be signed
disableCustomPrefix
string
Optional
Web3Auth only feature to skip singing popup. See more details here

Returns

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

Example

await startrailSdk().signMessage('sample')

switchLanguage

Switch language for Web3Auth wallet UI

Arguments

Parameter
Type
Mandatory
Description
lang
"ja" | "en"
Required
Web3Auth only feature to switch language

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()

About Page reload and data persistency

  • 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
©2023 Startbahn, Inc.