@startbahn/startrail-sdk-js v1.35.0
startrail-sdk-js
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.
Install
yarn add @startbahn/startrail-sdk-js
# or
npm i @startbahn/startrail-sdk-js
Or as a script tag:
jsdeliver
<script src="https://cdn.jsdelivr.net/npm/@startbahn/startrail-sdk-js"></script>
unpkg
<script src="https://unpkg.com/@startbahn/startrail-sdk-js"></script>
Usage
const startrail = new Startrail(params)
Note: No need to pass params if you want to use Startrail production endpoint with associated Auth0 & TORUS features.
Parameters
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/Passwordproduction
: 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 preferencesen
: Englishja
: Japanese
loginProvider
(optional): Login provider preferenceemail_password
: Email Password logingoogle
: Google Oauth Login
customUi
: Customising UI. If no parameters are set, default values are applied.logoUrl
: Applied to all logos in Startrail-sdk-jsserviceName
: Applied to all service name in Startrail-sdk-jscontactUrl
: Applied to the contact email in signup EmailverificationEmailTitle
: Applied to the title of the verification email when you select email_passwordwords
: See more details in Example sectionlogoWhiteUrl
: 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 verificationwithModal
(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/signupchainId
(optional): chainId of EVM based blockchain that is accessed from the wallet you login/signup
torusBuildEnv
(optional): Alias forenv
.
Example
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'
}
}
}
}
})
Tips
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.
1 month ago
1 month ago
2 months ago
2 months ago
4 months ago
8 months ago
8 months ago
8 months ago
11 months ago
11 months ago
11 months ago
11 months ago
6 months ago
6 months ago
6 months ago
8 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
9 months ago
8 months ago
10 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago