Bootstrap Etherspot SDK
The bare minimum to get you started.
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.
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:
Got an idea? Prototype it now on the Etherspot Playground
Learn how to work with Multi-chain Transactions
Last updated
Was this helpful?