Before doing anything with the SDK, we must instantiate it. This will create the Etherspot smart account based off of the values we pass in.

Step 1. Import the Etherspot Prime SDK.

  import { PrimeSdk } from '@etherspot/prime-sdk';

Step 2. Instantiate the SDK with a private key and Chain ID using this block of code.

  const primeSdk = new PrimeSdk(
    { privateKey: process.env.WALLET_PRIVATE_KEY }, 
    { 
      chainId: Number(process.env.CHAIN_ID), 
    },
  );

And that’s it! You’re now ready to call any of the Prime SDK functions.

You can also pass in different parameters when instantiating the SDK.

  • chainId : The chain ID of the blockchain.
  • entryPointAddress : The 4337 entry point address you wish to use.
  • bundlerRpcUrl : The bundler you wish to use.
  • walletFactoryAddress : The wallet factory implementation you wish to use.

An example of how to configure this is shown below:

  const primeSdk = new PrimeSdk(
    { privateKey: process.env.WALLET_PRIVATE_KEY },
    {
      chainId: 123,
      entryPointAddress: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
      rpcProviderUrl: 'https://fusetestnet-bundler.etherspot.io/',
      walletFactoryAddress: '0x7f6d8F107fE8551160BD5351d5F1514A6aD5d40E',
    },
  );

You can check primeSdk.state() to check if the Etherspot network is up and running correctly.

In the next page we’ll take a look at the various functions the SDK offers.