Router Chain TypeScript SDK
Introduction
Router Chain Ts SDK is a SDK which is used to Build CrossChain DApps on Router Chain. Refer this Documentation to Learn in-detail about the Methods available in Ts SDK Package.
Now, Let’s Explore Some of the functions available.
Setting Up the Project
-
Navigate to your Desired Workspace Directory and Create a new Directory for your Project using the
mkdir
Command andcd
to that directory - -
Initialize a
package.json
file, which will Manage your Project’s Dependencies, usingyarn
- -
Install TypeScript as a Development Dependency using
yarn
- -
Generate a Basic TypeScript Configuration file using the TypeScript Compiler -
This creates a
tsconfig.json
file at the Root of your Project. It defines Compiler Options for how TypeScript code will be Transpiled to JavaScript. -
Create a New file for your Application code with a
.ts
Extension (e.g., index.ts) - -
Since TypeScript Code needs to be Compiled to JavaScript before
NodeJS
can Execute it, you’ll use thets-node
Package for Development -Install
ts-node
as a Development Dependency: -
Install the Latest Version of Asset Transfer SDK -
Fetching an Account’s Balance
Refer the Below SDK Implementation to Understand how to fetch an Account’s Balance.
Possible Errors
For using the SDK with UI it is recommended to use Node version v18.12.1 or above. If you get Webpack errors when using with create-react-app, follow these steps -
- Install
craco
and required packages.
- Add
craco.config.js
file in your project root.
- Replace these scripts in
package.json
.
-
yarn start
and the Webpack errors should be gone. -
If you get Webpack errors when using Vue’s nuxt framework, do this small change in
nuxt.config.js
build key -