Front-end Javascript/Typescript SDK
Startrail-sdk-js provides convenient access from your browser to Startrail API that sends transactions to Startrail Ethereum blockchain on behalf.
yarn add @startbahn/startrail-sdk-js
# or
npm i @startbahn/startrail-sdk-js
Or as a script tag:
<script src="https://cdn.jsdelivr.net/npm/@startbahn/startrail-sdk-js"></script>
<script src="https://unpkg.com/@startbahn/startrail-sdk-js"></script>
const startrail = new Startrail(params)
Note: No need to pass params if you want to use Startrail production endpoint with associated Auth0 & TORUS features.
[Common for all wallets]
-
apiPath
(optional): API endpointstartrail-sdk-js
calls. Default endpoint is set toproduction
. -
wallet
(optional): Activate selected wallet. Default isstartrail
.-
metamask
: Your Metamask wallet. -
startrail
: Google or Email/Passord powered by TORUS.
-
-
env
(optional): Environment that impacts on blockchain network, and EOA with startrail Email/Password-
production
: Matic network. TORUS production account and Startrail production Auth0 account. It is designed to communicate to Startrail production API. -
staging
: Amoy network. TORUS production account and Startrail staging Auth0 account. It is designed to communicate to Startrail staging API. -
lrc
: Amoy network. TORUS lrc account and Startrail qa Auth0 account. It is designed to communicate to Startrail qa API. -
local
: https://localhost:8545 network for local dev. TORUS lrc account and Startrail lrc Auth0 account. It is designed to communicate to localhost API.
-
[For Startrail wallet powered by TORUS]
-
authAction
(optional): Activate only selected action tab on the Email popup. Wording is also changed based on your choice. It points tosignup
login
-
auth0ClientId
(optional): Client ID of Auth0 account. -
auth0Domain
(optional): Domain of Auth0 associated withauth0ClientId
. -
auth0TorusConfigKey
(optional): Config key name for TORUS initialisation to connect Auth0 domain and TORUS network. This key is only provided by TORUS. -
lang
(optional): Language preferences-
en
: English -
ja
: Japanese
-
-
loginProvider
(optional): Login provider preference-
email_password
: Email Password login -
google
: Google Oauth Login
-
-
customUi
: Customising UI. If no parameters are set, default values are applied.-
logoUrl
: Applied to all logos in Startrail-sdk-js -
serviceName
: Applied to all service name in Startrail-sdk-js -
contactUrl
: Applied to the contact email in signup Email -
verificationEmailTitle
: Applied to the title of the verification email when you select email_password -
words
: See more details in Example section -
logoWhiteUrl
: Applied to all white logos on black background in Startrail-sdk-js
-
-
callbackUrl
(optional): Callback URL to redirect to from E-Mail template for signup verification -
withModal
(optional): Specifies if the Torus Login Provider Modal should be shown. Default value is set tofalse
-
rpcEndpoint
(optional): RpcEndpoint that is accessed from the wallet you login/signup -
chainId
(optional): chainId of EVM based blockchain that is accessed from the wallet you login/signup
[To be deprecate]
-
torusBuildEnv
(optional): Alias forenv
.
sdk = new Startrail({
apiPath:'http://localhost:3000/api/v1/',
env: 'lrc',
wallet: 'startrail',
authAction: { login: true, signup: false },
auth0ClientId: 'test-auth0-client-id',
auth0Domain: 'test.auth0.com',
auth0TorusConfigKey: 'test-auth0-key',
lang: 'ja',
loginProvider: 'email_password',
callbackUrl: 'https://www.sample.com',
withModal: true,
customUi: {
logoUrl: 'https://sample.com/logo',
logoWhiteUrl: 'https://sample.com/white-logo',
serviceName: 'your service',
verificationEmailTitle: 'your title',
contactUrl: 'contact@startrail.io',
words: {
en: {
modal: {
continueLogin: 'Login with previous {verifier} account', // {verifier} is optional but to be replaced programmatically with the login provider name if it exists in the sentence
termsConditions: 'your termsConditions',
termsConditionsLinkUrl: 'your termsConditionsLinkUrl',
privacyPolicyLinkUrl: 'your privacyPolicyLinkUrl'
},
signPopup: {
title: 'your title',
requestFrom: 'your requestFrom',
dataToSign: 'your dataToSign',
confirm: 'your Confirm',
cancel: 'your Cancel'
},
emailAuthPopup: {
titleLogin: 'your titleLogin',
titleSignup: 'your titleSignup'
}
},
ja: {
modal: {
continueLogin: '前回の{verifier}アカウントを使う', // {verifier}は任意ですが、文言の中に存在していれば選択したログイン方法の名前へと自動的に置き換わります。
termsConditions: 'あなたの termsConditions',
termsConditionsLinkUrl: 'あなたの termsConditionsLinkUrl',
privacyPolicyLinkUrl: 'あなたの privacyPolicyLinkUrl'
},
signPopup: {
title: 'あなたの title',
requestFrom: 'あなたの requestFrom',
dataToSign: 'あなたの dataToSign',
confirm: 'あなたの Confirm',
cancel: 'あなたの Cancel'
},
emailAuthPopup: {
titleLogin: 'あなたの titleLogin',
titleSignup: 'あなたの titleSignup'
}
}
}
}
})
If you use Metamask, call sdk.login() before requesting users to sign or call API, in order to fetch currently active EOA and compare it in your web-application, because it is not possible by SDK to stop users from switching EOA.