# Context

Context in which the SDK is being used

* Holds the current low level API
* Holds the current keyring pair
* Holds the current Identity

## Hierarchy

* **Context**

## Index

### Properties

* [currentPair](#optional-currentpair)
* [isArchiveNode](#isarchivenode)
* [polymeshApi](#polymeshapi)

### Accessors

* [middlewareApi](#middlewareapi)

### Methods

* [accountBalance](#accountbalance)
* [getAccounts](#getaccounts)
* [getCurrentAccount](#getcurrentaccount)
* [getCurrentIdentity](#getcurrentidentity)
* [getCurrentPair](#getcurrentpair)
* [getInvalidDids](#getinvaliddids)
* [getLatestBlock](#getlatestblock)
* [getSecondaryKeys](#getsecondarykeys)
* [getSigner](#getsigner)
* [getTransactionArguments](#gettransactionarguments)
* [getTransactionFees](#gettransactionfees)
* [isMiddlewareAvailable](#ismiddlewareavailable)
* [isMiddlewareEnabled](#ismiddlewareenabled)
* [issuedClaims](#issuedclaims)
* [queryMiddleware](#querymiddleware)
* [setPair](#setpair)
* [create](#static-create)

## Properties

### `Optional` currentPair

• **currentPair**? : [*KeyringPair*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/keyringpair)

*Defined in* [*src/base/Context.ts:83*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L83)

### isArchiveNode

• **isArchiveNode**: *boolean* = false

*Defined in* [*src/base/Context.ts:88*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L88)

Whether the current node is an archive node (contains a full history from genesis onward) or not

### polymeshApi

• **polymeshApi**: *ApiPromise*

*Defined in* [*src/base/Context.ts:81*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L81)

## Accessors

### middlewareApi

• **get middlewareApi**(): *ApolloClient‹NormalizedCacheObject›*

*Defined in* [*src/base/Context.ts:777*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L777)

Retrieve the middleware client

**`throws`** if the middleware is not enabled

**Returns:** *ApolloClient‹NormalizedCacheObject›*

## Methods

### accountBalance

▸ **accountBalance**(`account?`: string | [Account](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/account)): *Promise‹*[*AccountBalance*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountbalance)*›*

*Defined in* [*src/base/Context.ts:226*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L226)

Retrieve the account level POLYX balance

**`note`** can be subscribed to

**Parameters:**

| Name       | Type                                                                                                        |
| ---------- | ----------------------------------------------------------------------------------------------------------- |
| `account?` | string \| [Account](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/account) |

**Returns:** *Promise‹*[*AccountBalance*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountbalance)*›*

▸ **accountBalance**(`account`: string | [Account](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/account) | undefined, `callback`: [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#subcallback)‹[AccountBalance](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountbalance)›): *Promise‹*[*UnsubCallback*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#unsubcallback)*›*

*Defined in* [*src/base/Context.ts:227*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L227)

Retrieve the account level POLYX balance

**`note`** can be subscribed to

**Parameters:**

| Name       | Type                                                                                                                                                                                                                          |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account`  | string \| [Account](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/account) \| undefined                                                                                                      |
| `callback` | [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#subcallback)‹[AccountBalance](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountbalance)› |

**Returns:** *Promise‹*[*UnsubCallback*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#unsubcallback)*›*

### getAccounts

▸ **getAccounts**(): *Array‹*[*AccountData*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountdata)*›*

*Defined in* [*src/base/Context.ts:199*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L199)

Retrieve a list of addresses associated with the account

**Returns:** *Array‹*[*AccountData*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/accountdata)*›*

### getCurrentAccount

▸ **getCurrentAccount**(): [*CurrentAccount*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/currentaccount)

*Defined in* [*src/base/Context.ts:285*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L285)

Retrieve current Account

**`throws`** if there is no current account associated to the SDK instance

**Returns:** [*CurrentAccount*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/currentaccount)

### getCurrentIdentity

▸ **getCurrentIdentity**(): *Promise‹*[*CurrentIdentity*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/currentidentity)*›*

*Defined in* [*src/base/Context.ts:305*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L305)

Retrieve current Identity

**`throws`** if there is no Identity associated to the current Account (or there is no current Account associated to the SDK instance)

**Returns:** *Promise‹*[*CurrentIdentity*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/currentidentity)*›*

### getCurrentPair

▸ **getCurrentPair**(): [*KeyringPair*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/keyringpair)

*Defined in* [*src/base/Context.ts:325*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L325)

Retrieve current Keyring Pair

**`throws`** if there is no Account associated to the SDK instance

**Returns:** [*KeyringPair*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/keyringpair)

### getInvalidDids

▸ **getInvalidDids**(`identities`: (string | [Identity](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/identity)‹›)\[]): *Promise‹string\[]›*

*Defined in* [*src/base/Context.ts:353*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L353)

Check whether Identities exist

**Parameters:**

| Name         | Type                                                                                                                 |
| ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `identities` | (string \| [Identity](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/identity)‹›)\[] |

**Returns:** *Promise‹string\[]›*

### getLatestBlock

▸ **getLatestBlock**(): *Promise‹BigNumber›*

*Defined in* [*src/base/Context.ts:835*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L835)

Retrieve the latest block number

**Returns:** *Promise‹BigNumber›*

### getSecondaryKeys

▸ **getSecondaryKeys**(): *Promise‹*[*SecondaryKey*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/secondarykey)*\[]›*

*Defined in* [*src/base/Context.ts:551*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L551)

Retrieve the list of secondary keys related to the Account

**`note`** can be subscribed to

**Returns:** *Promise‹*[*SecondaryKey*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/secondarykey)*\[]›*

▸ **getSecondaryKeys**(`callback`: [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#subcallback)‹[SecondaryKey](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/secondarykey)\[]›): *Promise‹*[*UnsubCallback*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#unsubcallback)*›*

*Defined in* [*src/base/Context.ts:552*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L552)

**Parameters:**

| Name       | Type                                                                                                                                                                                                                         |
| ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `callback` | [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#subcallback)‹[SecondaryKey](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/secondarykey)\[]› |

**Returns:** *Promise‹*[*UnsubCallback*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#unsubcallback)*›*

### getSigner

▸ **getSigner**(): *AddressOrPair*

*Defined in* [*src/base/Context.ts:340*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L340)

Retrieve the signer address (or keyring pair)

**Returns:** *AddressOrPair*

### getTransactionArguments

▸ **getTransactionArguments**(`args`: object): [*TransactionArgument*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#transactionargument)*\[]*

*Defined in* [*src/base/Context.ts:403*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L403)

Retrieve the types of arguments that a certain transaction requires to be run

**Parameters:**

▪ **args**: *object*

| Name  | Type  | Description                                                                      |
| ----- | ----- | -------------------------------------------------------------------------------- |
| `tag` | TxTag | tag associated with the transaction that will be executed if the proposal passes |

**Returns:** [*TransactionArgument*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#transactionargument)*\[]*

### getTransactionFees

▸ **getTransactionFees**(`tag`: TxTag): *Promise‹BigNumber›*

*Defined in* [*src/base/Context.ts:376*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L376)

Retrieve the protocol fees associated with running a specific transaction

**Parameters:**

| Name  | Type  | Description                                                            |
| ----- | ----- | ---------------------------------------------------------------------- |
| `tag` | TxTag | transaction tag (i.e. TxTags.asset.CreateAsset or "asset.createAsset") |

**Returns:** *Promise‹BigNumber›*

### isMiddlewareAvailable

▸ **isMiddlewareAvailable**(): *Promise‹boolean›*

*Defined in* [*src/base/Context.ts:822*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L822)

Return whether the middleware is enabled and online

**Returns:** *Promise‹boolean›*

### isMiddlewareEnabled

▸ **isMiddlewareEnabled**(): *boolean*

*Defined in* [*src/base/Context.ts:815*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L815)

Return whether the middleware was enabled at startup

**Returns:** *boolean*

### issuedClaims

▸ **issuedClaims**(`opts`: object): *Promise‹*[*ResultSet*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/resultset)*‹*[*ClaimData*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/claimdata)*››*

*Defined in* [*src/base/Context.ts:726*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L726)

Retrieve a list of claims. Can be filtered using parameters

**`note`** uses the middleware (optional)

**Parameters:**

▪`Default value` **opts**: *object*= {}

| Name                   | Type                                                                                                                 | Description                                                                               |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `claimTypes?`          | [ClaimType](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/enums/claimtype)\[]               | types of the claims to fetch. Defaults to any type                                        |
| `includeExpired?`      | undefined \| false \| true                                                                                           | whether to include expired claims. Defaults to true                                       |
| `size?`                | undefined \| number                                                                                                  | page size                                                                                 |
| `start?`               | undefined \| number                                                                                                  | page offset                                                                               |
| `targets?`             | (string \| [Identity](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/identity)‹›)\[] | identities (or Identity IDs) for which to fetch claims (targets). Defaults to all targets |
| `trustedClaimIssuers?` | (string \| [Identity](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/identity)‹›)\[] | identity IDs of claim issuers. Defaults to all claim issuers                              |

**Returns:** *Promise‹*[*ResultSet*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/resultset)*‹*[*ClaimData*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/claimdata)*››*

### queryMiddleware

▸ **queryMiddleware**‹**Result**›(`query`: GraphqlQuery‹unknown›): *Promise‹ApolloQueryResult‹Result››*

*Defined in* [*src/base/Context.ts:793*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L793)

Make a query to the middleware server using the apollo client

**Type parameters:**

▪ **Result**: *Partial‹Query›*

**Parameters:**

| Name    | Type                  |
| ------- | --------------------- |
| `query` | GraphqlQuery‹unknown› |

**Returns:** *Promise‹ApolloQueryResult‹Result››*

### setPair

▸ **setPair**(`address`: string): *Promise‹void›*

*Defined in* [*src/base/Context.ts:209*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L209)

Set a pair as the current account keyring pair

**Parameters:**

| Name      | Type   |
| --------- | ------ |
| `address` | string |

**Returns:** *Promise‹void›*

### `Static` create

▸ **create**(`params`: object): *Promise‹*[*Context*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/context)*›*

*Defined in* [*src/base/Context.ts:122*](https://github.com/PolymathNetwork/polymesh-sdk/blob/a0872cf4/src/base/Context.ts#L122)

Create the Context instance

**Parameters:**

▪ **params**: *object*

| Name               | Type                                                                                                                                                                                                                      |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountMnemonic?` | undefined \| string                                                                                                                                                                                                       |
| `accountSeed?`     | undefined \| string                                                                                                                                                                                                       |
| `accountUri?`      | undefined \| string                                                                                                                                                                                                       |
| `keyring?`         | [CommonKeyring](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/globals#commonkeyring) \| [UiKeyring](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/interfaces/uikeyring) |
| `middlewareApi`    | ApolloClient‹NormalizedCacheObject› \| null                                                                                                                                                                               |
| `polymeshApi`      | ApiPromise                                                                                                                                                                                                                |

**Returns:** *Promise‹*[*Context*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v4/classes/context)*›*
