The JavaScript SDK supports EVM and Substrate transactions. In order to communicate and generate transactions using the peaq blockchain an instance must be created.

createInstance(baseUrl, chainType, seed)

ParameterTypeEVMSubstrateDescription
baseUrlstringRequiredRequiredRPC/WSS URL used to connect to the blockchain. Reference Connecting to peaq for supported URLs. Use RPC for EVM and WSS for Substrate (and EVM reads).
chainTypeChainTypeRequiredOptionalDefines whether the instance will generate EVM or Substrate transactions (defaults to Substrate). Accessible via the SDK.
seedstringN/AOptionalMnemonic phrase used in Substrate instances to execute write transactions on behalf of the user.
import { Sdk } from "@peaq-network/sdk";

const HTTPS_BASE_URL = "https://peaq.api.onfinality.io/public";

const sdk = await Sdk.createInstance({
    baseUrl: HTTPS_BASE_URL,
    chainType: Sdk.ChainType.EVM
});

// No direct API connection made to EVM so disconnect is unnecessary.

Now you will have an sdk object that can be used to execute the DID, RBAC, and Storage operations on the peaq blockchain.

The EVM instance only constructs transactions objects, and does not send the transactions itself. This gives the user the ability to send peaq transactions themselves without ever sending a private key through the sdk. However, if you would like this process abstracted away, we do provide a Send Evm Transaction function. To mitigate concerns on how we use your seed/private key we have made our peaq js SDK fully open source.