# 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)
* [ss58Format](#ss58format)

### Accessors

* [middlewareApi](#middlewareapi)

### Methods

* [accountBalance](#accountbalance)
* [accountSubsidy](#accountsubsidy)
* [addPair](#addpair)
* [clone](#clone)
* [disconnect](#disconnect)
* [getAccounts](#getaccounts)
* [getCurrentAccount](#getcurrentaccount)
* [getCurrentIdentity](#getcurrentidentity)
* [getCurrentPair](#getcurrentpair)
* [getInvalidDids](#getinvaliddids)
* [getLatestBlock](#getlatestblock)
* [getNetworkVersion](#getnetworkversion)
* [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://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/keyringpair.md)

*Defined in* [*src/base/Context.ts:111*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L111)

***

### isArchiveNode

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

*Defined in* [*src/base/Context.ts:116*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L116)

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:109*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L109)

***

### ss58Format

• **ss58Format**: *number*

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

## Accessors

### middlewareApi

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

*Defined in* [*src/base/Context.ts:1001*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1001)

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/v11.0.2/classes/account)): *Promise‹*[*AccountBalance*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#accountbalance)*›*

*Defined in* [*src/base/Context.ts:328*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L328)

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/v11.0.2/classes/account) |

**Returns:** *Promise‹*[*AccountBalance*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#accountbalance)*›*

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

*Defined in* [*src/base/Context.ts:329*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L329)

**Parameters:**

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

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

***

### accountSubsidy

▸ **accountSubsidy**(`account?`: string | [Account](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account)): *Promise‹Omit‹*[*Subsidy*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/subsidy.md)*, "beneficiary"› | null›*

*Defined in* [*src/base/Context.ts:382*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L382)

Retrieve the account level subsidizer relationship. If there is no such relationship, return null

**`note`** can be subscribed to

**Parameters:**

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

**Returns:** *Promise‹Omit‹*[*Subsidy*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/subsidy.md)*, "beneficiary"› | null›*

▸ **accountSubsidy**(`account`: string | [Account](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account) | undefined, `callback`: [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#subcallback)‹Omit‹[Subsidy](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/subsidy.md), "beneficiary"› | null›): *Promise‹*[*UnsubCallback*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#unsubcallback)*›*

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

**Parameters:**

| Name       | Type                                                                                                                                                                                                                                        |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `account`  | string \| [Account](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account) \| undefined                                                                                                                    |
| `callback` | [SubCallback](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#subcallback)‹Omit‹[Subsidy](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/subsidy.md), "beneficiary"› \| null› |

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

***

### addPair

▸ **addPair**(`params`: [AddPairParams](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#addpairparams)): [*KeyringPair*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/keyringpair.md)

*Defined in* [*src/base/Context.ts:263*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L263)

Add a signing pair to the Keyring

**Parameters:**

| Name     | Type                                                                                                          |
| -------- | ------------------------------------------------------------------------------------------------------------- |
| `params` | [AddPairParams](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/globals#addpairparams) |

**Returns:** [*KeyringPair*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/keyringpair.md)

***

### clone

▸ **clone**(): [*Context*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/context)

*Defined in* [*src/base/Context.ts:1098*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1098)

Returns a (shallow) clone of this instance. Useful for providing a separate Context to Procedures with different signers

**Returns:** [*Context*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/context)

***

### disconnect

▸ **disconnect**(): *Promise‹void›*

*Defined in* [*src/base/Context.ts:1080*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1080)

Disconnect the Polkadot API, middleware, and render this instance unusable

**`note`** after disconnecting, trying to access any property in this objecct will result in an error

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

***

### getAccounts

▸ **getAccounts**(): [*Account*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account)*\[]*

*Defined in* [*src/base/Context.ts:240*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L240)

Retrieve a list of Accounts that can act as signers. The first Account in the array is the current Account (default signer)

**Returns:** [*Account*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account)*\[]*

***

### getCurrentAccount

▸ **getCurrentAccount**(): [*Account*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account)

*Defined in* [*src/base/Context.ts:438*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L438)

Retrieve current Account

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

**Returns:** [*Account*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/account)

***

### getCurrentIdentity

▸ **getCurrentIdentity**(): *Promise‹*[*Identity*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/identity)*›*

*Defined in* [*src/base/Context.ts:449*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L449)

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‹*[*Identity*](https://developers.polymath.network/polymesh-sdk-api-reference/v11.0.2/classes/identity)*›*

***

### getCurrentPair

▸ **getCurrentPair**(): [*KeyringPair*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/keyringpair.md)

*Defined in* [*src/base/Context.ts:469*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L469)

Retrieve current Keyring Pair

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

**Returns:** [*KeyringPair*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/keyringpair.md)

***

### getInvalidDids

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

*Defined in* [*src/base/Context.ts:498*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L498)

Check whether Identities exist

**Parameters:**

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

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

***

### getLatestBlock

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

*Defined in* [*src/base/Context.ts:1059*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1059)

Retrieve the latest block number

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

***

### getNetworkVersion

▸ **getNetworkVersion**(): *Promise‹string›*

*Defined in* [*src/base/Context.ts:1068*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1068)

Retrieve the network version

**Returns:** *Promise‹string›*

***

### getSigner

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

*Defined in* [*src/base/Context.ts:485*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L485)

Retrieve the signer address (or keyring pair)

**Returns:** *AddressOrPair*

***

### getTransactionArguments

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

*Defined in* [*src/base/Context.ts:554*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L554)

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

***

### getTransactionFees

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

*Defined in* [*src/base/Context.ts:527*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L527)

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:1046*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1046)

Return whether the middleware is enabled and online

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

***

### isMiddlewareEnabled

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

*Defined in* [*src/base/Context.ts:1039*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1039)

Return whether the middleware was enabled at startup

**Returns:** *boolean*

***

### issuedClaims

▸ **issuedClaims**(`opts`: object): *Promise‹*[*ResultSet*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/resultset.md)*‹*[*ClaimData*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/claimdata.md)*››*

*Defined in* [*src/base/Context.ts:950*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L950)

Retrieve a list of claims. Can be filtered using parameters

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

**Parameters:**

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

| Name                   | Type                                                                                                                                                                                                                                                                                                                                                      | Description                                                                               |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `claimTypes?`          | [Exclude](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/enums/targettreatment.md#exclude)‹[ClaimType](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/enums/claimtype.md), [InvestorUniquenessV2](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/enums/claimtype.md#investoruniquenessv2)›\[] | 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/v11.0.2/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/v11.0.2/classes/identity)‹›)\[]                                                                                                                                                                                                                                      | identity IDs of claim issuers. Defaults to all claim issuers                              |

**Returns:** *Promise‹*[*ResultSet*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/resultset.md)*‹*[*ClaimData*](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/claimdata.md)*››*

***

### queryMiddleware

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

*Defined in* [*src/base/Context.ts:1017*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L1017)

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): *void*

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

Set a pair as the current Account keyring pair

**Parameters:**

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

**Returns:** *void*

***

### `Static` create

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

*Defined in* [*src/base/Context.ts:165*](https://github.com/PolymathNetwork/polymesh-sdk/blob/da0f7fd7/src/base/Context.ts#L165)

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/v11.0.2/globals#commonkeyring) \| [UiKeyring](https://github.com/PolymathNetwork/polymesh-sdk/blob/docs/v11/docs/interfaces/uikeyring.md) |
| `middlewareApi`    | ApolloClient‹NormalizedCacheObject› \| null                                                                                                                                                                              |
| `polymeshApi`      | ApiPromise                                                                                                                                                                                                               |

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