TypeScript SDK
Setup
Learn how to setup the TypeScript SDK.
Prerequisites
We require node version 18 or later version and npm version 8 to be installed in your environment. To install node and npm, we recommend you go to the Node.js official website and download the latest LTS (Long Term Support) version.
Install the Dependencies
Install the Story SDK node package, as well as viem.
Initiate SDK Client
Next we can initiate the SDK Client. There are two ways to do this:
- Using a private key (preferable for some backend admin)
- JSON-RPC account like Metamask where users sign their own transactions
Set Up Private Key Account
Before continuing with the code below:
- Make sure to have
WALLET_PRIVATE_KEY
set up in your.env
file. - Make sure to have
RPC_PROVIDER_URL
set up in your.env
file.- You can use the public default one (
https://aeneid.storyrpc.io
) or check out the other RPCs here.
- You can use the public default one (
utils.ts
Setup for React (ex. Metamask)
The React Setup Guide shows how we can also use the TypeScript SDK to delay signing & sending transactions to a JSON-RPC account like Metamask.