Create an Account
Overview
This documentation will guide you through the process of creating an account and retrieving the account address for trading.
Prerequisites
Before opening a position, ensure that you have completed the following steps:
- Set up the Chromatic Protocol SDK by following the installation instructions.
Creating an Account
Before you can start trading on the Chromatic Protocol, you need to create an account. The account creation process associates your Ethereum address with the SDK.
To create an account, use the createAccount
method of the ChromaticAccount
instance:
- ethers-v5
- ethers-v6
- viem
import { Client } from "@chromatic-protocol/sdk-ethers-v5"
const client: Client = ... // Replace with your instantiated Client object
await client.account().createAccount();
import { Client } from "@chromatic-protocol/sdk-ethers-v6"
const client: Client = ... // Replace with your instantiated Client object
await client.account().createAccount();
import { Client } from "@chromatic-protocol/sdk-viem"
const client: Client = ... // Replace with your instantiated Client object
await client.account().createAccount();
The createAccount
method is asynchronous and returns a Promise, so you need to use await
to wait for the account creation process to complete.
Retrieving the Account Address
Once the account is created, you can retrieve the associated account address using the getAccount
method:
const accountAddress = await client.account().getAccount()
The getAccount
method is also asynchronous and returns a Promise that resolves to the Ethereum address of the account.