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:

  1. PUBLIC_URL

  2. PINATA_API_KEY

  3. PINATA_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:

  1. Import the necessary libraries:

    import { NotVault } from '@notcentralised/notvault-sdk';
    import { ethers } from 'ethers';
  2. Instantiate the NotVault class:

    const vault = new NotVault();
  3. Create an JSON RPC connection:

    • Set up a new instance of JsonRpcProvider from the ethers library. You need to pass in your RPC Host URL to the JsonRpcProvider constructor.

    • Create a signer by creating a new instance of the Wallet class from the ethers library. 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);
  4. Initialise the vault object: Now, using the .init function of the vault instance, pass in your Chain ID and the signer instance 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