Skip to content

api.client.Polymesh.Polymesh

prashantasdeveloper edited this page Dec 2, 2024 · 67 revisions

Class: Polymesh

api/client/Polymesh.Polymesh

Main entry point of the Polymesh SDK

Table of contents

Properties

Accessors

Methods

Properties

accountManagement

accountManagement: AccountManagement

A set of methods for managing a Polymesh Identity's Accounts and their permissions

Defined in

api/client/Polymesh.ts:109


assets

assets: Assets

A set of methods for interacting with Assets

Defined in

api/client/Polymesh.ts:117


claims

claims: Claims

A set of methods to deal with Claims

Defined in

api/client/Polymesh.ts:97


identities

identities: Identities

A set of methods for interacting with Polymesh Identities.

Defined in

api/client/Polymesh.ts:113


network

network: Network

A set of methods to interact with the Polymesh network. This includes transferring POLYX, reading network properties and querying for historical events

Defined in

api/client/Polymesh.ts:101


settlements

settlements: Settlements

A set of methods for exchanging Assets

Defined in

api/client/Polymesh.ts:105

Accessors

_middlewareApiV2

get _middlewareApiV2(): ApolloClient<NormalizedCacheObject>

MiddlewareV2 client

Returns

ApolloClient<NormalizedCacheObject>

Defined in

api/client/Polymesh.ts:357


_polkadotApi

get _polkadotApi(): ApiPromise

Polkadot client

Returns

ApiPromise

Defined in

api/client/Polymesh.ts:341


_signingAddress

get _signingAddress(): string

signing address (to manually submit transactions with the polkadot API)

Returns

string

Defined in

api/client/Polymesh.ts:349

Methods

createTransactionBatch

createTransactionBatch<ReturnValues>(args, opts?): Promise<GenericPolymeshTransaction<ReturnValues, ReturnValues>>

Create a batch transaction from a list of separate transactions. The list can contain batch transactions as well. The result of running this transaction will be an array of the results of each transaction in the list, in the same order. Transactions with no return value will produce undefined in the resulting array

Type parameters

Name Type
ReturnValues extends readonly unknown[]

Parameters

Name Type
args CreateTransactionBatchParams<ReturnValues>
opts? ProcedureOpts

Returns

Promise<GenericPolymeshTransaction<ReturnValues, ReturnValues>>

Example

Batching 3 ticker reservation transactions

const tx1 = await sdk.assets.reserveTicker({ ticker: 'FOO' });
const tx2 = await sdk.assets.reserveTicker({ ticker: 'BAR' });
const tx3 = await sdk.assets.reserveTicker({ ticker: 'BAZ' });

const batch = sdk.createTransactionBatch({ transactions: [tx1, tx2, tx3] as const });

const [res1, res2, res3] = await batch.run();

Example

Specifying the signer account for the whole batch

const batch = sdk.createTransactionBatch({ transactions: [tx1, tx2, tx3] as const }, { signingAccount: 'someAddress' });

const [res1, res2, res3] = await batch.run();

Note

it is mandatory to use the as const type assertion when passing in the transaction array to the method in order to get the correct types for the results of running the batch

Note

if a signing Account is not specified, the default one will be used (the one returned by sdk.accountManagement.getSigningAccount())

Note

all fees in the resulting batch must be paid by the calling Account, regardless of any exceptions that would normally be made for the individual transactions (such as subsidies or accepting invitations to join an Identity)

Note

this method is of type CreateTransactionBatchProcedureMethod, which means you can call createTransactionBatch.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it

Defined in

api/client/Polymesh.ts:332


disconnect

disconnect(): Promise<void>

Disconnect the client and close all open connections and subscriptions

Returns

Promise<void>

Note

the SDK will become unusable after this operation. It will throw an error when attempting to access any chain or middleware data. If you wish to continue using the SDK, you must create a new instance by calling connect

Defined in

api/client/Polymesh.ts:274


getSigningIdentity

getSigningIdentity(): Promise<null | Identity>

Retrieve the Identity associated to the signing Account (null if there is none)

Returns

Promise<null | Identity>

Throws

if there is no signing Account associated to the SDK

Defined in

api/client/Polymesh.ts:229


onConnectionError

onConnectionError(callback): UnsubCallback

Handle connection errors

Parameters

Name Type
callback (...args: unknown[]) => unknown

Returns

UnsubCallback

an unsubscribe callback

Defined in

api/client/Polymesh.ts:238


onDisconnect

onDisconnect(callback): UnsubCallback

Handle disconnection

Parameters

Name Type
callback (...args: unknown[]) => unknown

Returns

UnsubCallback

an unsubscribe callback

Defined in

api/client/Polymesh.ts:255


setSigningAccount

setSigningAccount(signer): Promise<void>

Set the SDK's signing Account to the provided one

Parameters

Name Type
signer string | Account

Returns

Promise<void>

Throws

if the passed Account is not present in the Signing Manager (or there is no Signing Manager)

Defined in

api/client/Polymesh.ts:283


setSigningManager

setSigningManager(signingManager): Promise<void>

Set the SDK's Signing Manager to the provided one.

Parameters

Name Type
signingManager null | SigningManager

Returns

Promise<void>

Note

Pass null to unset the current signing manager

Defined in

api/client/Polymesh.ts:292


connect

Static connect(params): Promise<Polymesh>

Create an SDK instance and connect to a Polymesh node

Parameters

Name Type
params ConnectParams

Returns

Promise<Polymesh>

Defined in

api/client/Polymesh.ts:150

Clone this wiki locally