# 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-v3/interfaces/keyringpair)

*Defined in* [*src/base/Context.ts:76*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L76)

### isArchiveNode

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

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

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:74*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L74)

## Accessors

### middlewareApi

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

*Defined in* [*src/base/Context.ts:670*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L670)

Retrieve the middleware client

**`throws`** if cred entials are not set

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

## Methods

### accountBalance

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

*Defined in* [*src/base/Context.ts:233*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L233)

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-v3/classes/account) |

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

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

*Defined in* [*src/base/Context.ts:234*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L234)

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-v3/classes/account) \| undefined                                                                                                      |
| `callback` | [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v3/globals#subcallback)‹[AccountBalance](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v3/interfaces/accountbalance)› |

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

### getAccounts

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

*Defined in* [*src/base/Context.ts:206*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L206)

Retrieve a list of addresses associated with the account

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

### getCurrentAccount

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

*Defined in* [*src/base/Context.ts:292*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L292)

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-v3/classes/currentaccount)

### getCurrentIdentity

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

*Defined in* [*src/base/Context.ts:312*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L312)

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-v3/classes/currentidentity)*›*

### getCurrentPair

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

*Defined in* [*src/base/Context.ts:332*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L332)

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-v3/interfaces/keyringpair)

### getInvalidDids

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

*Defined in* [*src/base/Context.ts:360*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L360)

Check whether Identities exist

**Parameters:**

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

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

### getLatestBlock

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

*Defined in* [*src/base/Context.ts:728*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L728)

Retrieve the latest block number

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

### getSecondaryKeys

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

*Defined in* [*src/base/Context.ts:558*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L558)

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-v3/interfaces/secondarykey)*\[]›*

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

*Defined in* [*src/base/Context.ts:559*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L559)

**Parameters:**

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

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

### getSigner

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

*Defined in* [*src/base/Context.ts:347*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L347)

Retrieve the signer address (or keyring pair)

**Returns:** *AddressOrPair*

### getTransactionArguments

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

*Defined in* [*src/base/Context.ts:410*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L410)

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-v3/globals#transactionargument)*\[]*

### getTransactionFees

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

*Defined in* [*src/base/Context.ts:383*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L383)

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:715*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L715)

Return whether the middleware is enabled and online

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

### isMiddlewareEnabled

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

*Defined in* [*src/base/Context.ts:708*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L708)

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-v3/interfaces/resultset)*‹*[*ClaimData*](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v3/interfaces/claimdata)*››*

*Defined in* [*src/base/Context.ts:600*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L600)

Retrieve a list of claims. Can be filtered using parameters

**`note`** uses the middleware

**Parameters:**

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

| Name                   | Type                                                                                                                 | Description                                                                               |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `claimTypes?`          | [ClaimType](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v3/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-v3/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-v3/classes/identity)‹›)\[] | identity IDs of claim issuers. Defaults to all claim issuers                              |

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

### queryMiddleware

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

*Defined in* [*src/base/Context.ts:686*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L686)

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:216*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L216)

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-v3/classes/context)*›*

*Defined in* [*src/base/Context.ts:112*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L112)

Create the Context instance

**Parameters:**

▪ **params**: *object*

| Name            | Type                                        |
| --------------- | ------------------------------------------- |
| `middlewareApi` | ApolloClient‹NormalizedCacheObject› \| null |
| `polymeshApi`   | ApiPromise                                  |
| `seed`          | string                                      |

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

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

*Defined in* [*src/base/Context.ts:118*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L118)

Create the Context instance

**Parameters:**

▪ **params**: *object*

| Name            | Type                                                                                                          |
| --------------- | ------------------------------------------------------------------------------------------------------------- |
| `keyring`       | [CommonKeyring](https://developers.polymath.network/polymesh-sdk-api-reference/docs-v3/globals#commonkeyring) |
| `middlewareApi` | ApolloClient‹NormalizedCacheObject› \| null                                                                   |
| `polymeshApi`   | ApiPromise                                                                                                    |

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

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

*Defined in* [*src/base/Context.ts:124*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L124)

Create the Context instance

**Parameters:**

▪ **params**: *object*

| Name            | Type                                        |
| --------------- | ------------------------------------------- |
| `middlewareApi` | ApolloClient‹NormalizedCacheObject› \| null |
| `polymeshApi`   | ApiPromise                                  |
| `uri`           | string                                      |

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

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

*Defined in* [*src/base/Context.ts:130*](https://github.com/PolymathNetwork/polymesh-sdk/blob/1221e467/src/base/Context.ts#L130)

Create the Context instance

**Parameters:**

▪ **params**: *object*

| Name            | Type                                        |
| --------------- | ------------------------------------------- |
| `middlewareApi` | ApolloClient‹NormalizedCacheObject› \| null |
| `polymeshApi`   | ApiPromise                                  |

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