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

Getting Started

To start development with Startrail-Sdk-Js

NPM Package

Add Packages

npm
yarn
npm install @startbahn/startrail-sdk-js
yarn add @startbahn/startrail-sdk-js

Script Tag

jsdeliver
unpkg
<script src="https://cdn.jsdelivr.net/npm/@startbahn/startrail-sdk-js"></script><script src="https://unpkg.com/@startbahn/startrail-sdk-js"></script>
<script src="https://unpkg.com/@startbahn/startrail-sdk-js"></script>

Import

const StartrailSdk = require('@startbahn/startrail-sdk-js').Startrail
// or
import StartrailSdk from "@startbahn/startrail-sdk-js";
const startrail = new StartrailSdk(config)

Constructor

Configure and construct your Startrail SDK instance
new StartrailSdk(config)

Properties

All the properties listed below are optional.
Parameter
Type
Description
apiPath
string
Only define it if you want to do testing. For testing use the Test environment URL of STARTRAIL:
https://api-stg.startrail.startbahn.jp/api/v1
For production purpose do not define it.
wallet
'startrail' | 'metamask'
Wallet to activate. Default is startrail.
  • metamask: Metamask wallet installed in users' environment.
  • startrail: Google or Email/Password powered by Web3Auth.
env
string
The environment of Startrail-Api endpoint, blockchain network and Web3Auth environment.
  • production: Matic network. TORUS production account and Startrail production Auth0 account. It is designed to communicate to Startrail production API.
  • staging: Mumbai network. TORUS production account and Startrail staging Auth0 account. It is designed to communicate to Startrail for testing.
authAction
{
login: boolean
signup: boolean
}
true hashes the preimage with keccak256
auth0ClientId
string
Client ID of Auth0 account
auth0Domain
string
Domain URL of Auth0
auth0TorusConfigKey
string
Config key name for TORUS initialisations to connect Auth0 domain and Web3Auth network. This key is only provided by Web3Auth
lang
'ja' | 'en'
Language displayed on the UI
loginProvider
['google' | 'email_password' | 'facebook' | 'twitter' | 'line' | 'apple' | 'email_passwordless']
login providers for connecting wallet, more detail here.
customUi
CustomUI
Values to customise UI only under Startrail wallet powered by Web3Auth. See more details in Whitelabeling/Customizing section.
callbackUrl
string
A URL that a user is redirected to after verification completed from the email.
withModal
boolean
Startrail modal powered by Web3Auth is opened instead of direct procedure with a specific login action.
rpcEndpoint
string
An rpcEndpoint that is accessed from the wallet you select under the Startrail modal powered by Web3Auth, more detail here.
mfaLevel
"none" | "default" | "optional" | "mandatory"
default is none that is not asking for MFA. Further detail is here.

Things To Do In Advance

You need to give the Startbahn team your callbackUrl's base URL for approval to use it in the production environment. This isn't necessary for the staging environment. The base URL can look like this: https://YOUR_DOMAIN.com In the whitelist, the validation checks if the base URL ends with the given string. So, you can use a dynamic value for the URL (e.g.https://DYNAMIC_VALUE.YOUR_SERVICE_NAME.vercel.com/login) as long as the last string of the base URL, the postfix, matches what's in the whitelist. * whatever after "YOUR_DOMAIN.com" is not checked.

Sample Config Values For Each Login Method

All
Google
Email Password
Email Passwordless
Line
Facebook
Apple
Twitter
MetaMask
// For Production (*No need to set auth0 or apiPath)
sdk = new Startrail({
lang: 'ja',
withModal: true,
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
withModal: true,
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*No need to set auth0 or apiPath)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['google'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['google'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*No need to set auth0 or apiPath)
sdk = new Startrail({
authAction: { login: false, signup: true },
lang: 'ja',
loginProvider: ['email_password'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
redirectUrl: 'https://yoursite.com', // Not necessary for login
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
 authAction: { login: false, signup: true },
 apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
 lang: 'ja',
 loginProvider: ['email_password'],
 env: 'staging', // torusBuildEnv is deprecate after v1.25.0
 redirectUrl: 'https://yoursite.com', // Not necessary for login
 customUi: {
  logoUrl: 'https://yoursite.com/logo',
  serviceName: 'your service name'
 },
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*apiPath setting is not required)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['email_passwordless'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['email_passwordless'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*apiPath setting is not required)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['line'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['line'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*apiPath setting is not required)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['facebook'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['facebook'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*apiPath setting is not required)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['apple'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['apple'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*apiPath setting is not required)
sdk = new Startrail({
lang: 'ja',
loginProvider: ['twitter'],
env: 'production', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
lang: 'ja',
loginProvider: ['twitter'],
env: 'staging', // torusBuildEnv is deprecate after v1.25.0
customUi: {
logoUrl: 'https://yoursite.com/logo',
serviceName: 'your service name'
}
// rpcEndpoint: 'your rpc endpoint url' // IF you want to designate endpoint
})
// For Production (*No need to set auth0 or apiPath)
sdk = new Startrail({
env: 'production',
wallet: 'metamask'
})
// For Development
sdk = new Startrail({
apiPath: 'https://api-stg.startrail.startbahn.jp/api/v1',
env: 'staging',
wallet: 'metamask'
})
To connect to your wallet, use login method
await sdk.login()
See more details in Wallet Methods
Auth0 managed by Startbahn is used under the hood for some authentication method such as Email Password and LINE.
©2023 Startbahn, Inc.