Initialise
In order to begin using NotVault within your TypeScript projects, you will need to initialise the library correctly. This initialisation process sets up the necessary connections and providers for the library's operations, particularly for interacting with IPFS and the Ethereum blockchain via JSON-RPC.
Environment Variables
Prior to initializing NotVault, you'll need to ensure the following environment variables are set:
PUBLIC_URLPINATA_API_KEYPINATA_SECRET_API_KEY
These are critical for the functioning of IPFS file operations and the connectivity with Pinata.
Initialization Steps
To initialise NotVault in a TypeScript environment, follow the steps below:
Import the necessary libraries:
import { NotVault } from '@notcentralised/notvault-sdk'; import { ethers } from 'ethers';Instantiate the NotVault class:
const vault = new NotVault();Create an JSON RPC connection:
Set up a new instance of
JsonRpcProviderfrom theetherslibrary. You need to pass in your RPC Host URL to theJsonRpcProviderconstructor.Create a
signerby creating a new instance of theWalletclass from theetherslibrary. Pass in your private key and the custom HttpProvider instance.
const customHttpProvider = new ethers.providers.JsonRpcProvider('... RPC Host ...'); const signer = new ethers.Wallet('... Private Key ...', customHttpProvider);Initialise the vault object: Now, using the
.initfunction of thevaultinstance, pass in your Chain ID and thesignerinstance created in the previous step.vault.init('... Chain ID ...', signer);
After successfully following these steps, your NotVault instance is set up and ready for file operations on IPFS and transactions on an EVM compatible blockchain.
Last updated