nitrocourse

Module 10: Using Asset Transfer SDK: Part 1

Welcome to Module 10 of the Router Nitro Cookbook. This Module focuses on Utilizing the Asset Transfer SDK of Router Protocol. This SDK, available as an npm Package, Streamlines Asset Swapping between Blockchains. By installing the Package and importing required Libraries, you can Seamlessly Transfer Assets across Different Blockchains.

Prior to diving into SDK usage, let’s establish our initial Environment and install all necessary Libraries and Tools.

Step1: Setting up the project

To begin, open your preferred Code Editor. We’ll be using VS Code for this Tutorial. Next, ensure you have NodeJS installed. You can Download it from here Once NodeJS is installed, verify its installation by running node -v and npm -v in your Terminal. After Confirming NodeJS is set up Properly, Open VS Code and proceed with the following Steps.

Create a Project Directory:

  1. Navigate to your Desired Workspace Directory and Create a new Directory for your Project using the mkdir Command and cd to that directory -
mkdir my-nitro-project
cd my-nitro-project
  1. Initialize a package.json file, which will Manage your Project’s Dependencies, using Yarn -
yarn init -y
  1. Install TypeScript as a Development Dependency using Yarn -
yarn add -D typescript
  1. Generate a Basic TypeScript Configuration file using the TypeScript Compiler -
yarn tsc --init

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.

  1. Create a New file for your Application code with a .ts Extension (e.g., index.ts) -
touch index.ts
  1. Since TypeScript Code needs to be Compiled to JavaScript before NodeJS can Execute it, you’ll use the ts-node Package for Development -

Install ts-node as a Development Dependency:

yarn add -D ts-node
  1. Install the Latest Version of Asset Transfer SDK -
yarn add @routerprotocol/asset-transfer-sdk-ts

Share Your Learnings!

img

Share your learnings on Twitter. Click here

Next: Module 11: Using Asset Transfer SDK - Part 02