Skip to main content
The following examples in this section assume that you implement the guides on each page as separate functions and files under a single project directory. To set up your project, follow the steps below.
1

Create Directory

First, create a directory to store your project files.
mkdir initia-js-quickstart && cd initia-js-quickstart
2

Initialize Project

Next, initialize your project.
npm init && npm add -D typescript @types/node ts-node && npx tsc --init && mkdir src && echo 'async function example() { console.log("Running example!")}; example()' > src/quickstart.ts
3

Install InitiaJS

Install InitiaJS.
npm add @initia/initia.js
4

Test Installation

Once you have installed InitiaJS, test your installation. Replace the contents of src/quickstart.ts with the following code.
import { RESTClient, Coin } from '@initia/initia.js';

const restClient = new RESTClient('https://rest.testnet.initia.xyz');

(async () => { const chainId = await restClient.tendermint.chainId();
console.log(chainId); })();

Then, run the script.
npx ts-node src/quickstart.ts
If you get initiation-2 as the output, your installation was successful!