Bootstrap Etherspot SDK

The bare minimum to get you started.

Before you continue, please make sure you've checked the Requirements and performed the steps to Install Etherspot SDK.

As a bare minimum to use Etherspot, we recommend that you implement the following steps within your application.

Create an instance of the Etherspot SDK

This is where it all begins. You can check which EVM chains are supported on our Chains, Bridges & DEXes page. Then you can take a look at Instantiate Etherspot SDK to instantiate the SDK on one or multiple chains.

For the purposes of this guide, we're going to stick with Ethereum Mainnet.

Create a session

Next up, we create a session with our newly instantiated Etherspot SDK. This is useful for when you would like to authenticate / validate external clients with the Etherspot SDK instance.

import { Sdk } from 'etherspot';

const sdk: Sdk; // current sdk instance

async function main() {
  const output = await sdk.createSession();

  console.log('session object', output);
  console.log('session graphql headers', {
    ['x-auth-token']: output.token,
  });
}

Get your Etherspot Ethereum address

The next step is to get your Ethereum address from your Etherspot SDK.

import { Sdk } from 'etherspot';

const sdk: Sdk; // current sdk instance

async function main() {
  const output = await sdk.computeContractAccount();

  console.log('contract account', output);
}

Running the above code results in the following output:

{
  "address": "0x2f95595d9Bca08bA59110adF5e823c94955d82BB",
  "type": "Contract",
  "state": "UnDeployed",
  "store": "PersonalAccountRegistry",
  "createdAt": "[Date] 2021-07-10 00:10:26",
  "updatedAt": "[Date] 2021-07-10 00:10:26",
  "synchronizedAt": "[Date] 2021-07-10 00:10:24"
}

The output above shows the Etherspot service returning the state of your Etherspot SDK instance.

Key

Meaning

address

The Ethereum address that is assigned to your SDK instance.

type

This should only be Contract - and signals that this account is controlled by a Smart Contract.

state

Is either UnDeployed or Deployed.

store

Where this data is being stored. If you're using the hosted version of Etherspot, you can disregard this.

Providing that you use the same private key for each SDK instance against different chains, you will always get back the same Ethereum address. This means that your Ethereum address is the same across all chains. This is by design for convenience.

You're now ready to start building something with the Etherspot SDK! Why not take a look at the use cases from the navigation menu?

🚏 Here are some helpful links:

Last updated