api.client.Network - PolymeshAssociation/polymesh-sdk GitHub Wiki
@polymeshassociation/polymesh-sdk / api/client/Network
Defined in: api/client/Network.ts:56
Handles all Network related functionality, including querying for historical events from middleware
decodeCall(
hex):object
Defined in: api/client/Network.ts:567
Decode the SCALE-encoded call carried by a revive.ethTransact transaction (or any other
Polymesh call), so a dapp can render it next to a wallet's confirmation prompt. Does not
fix in-wallet legibility (the wallet still shows raw bytes); it removes the worst of the
opacity for a dapp that cares
| Parameter | Type | Description |
|---|---|---|
hex |
`0x${string}` |
SCALE-encoded call, e.g. transaction.toEthSignablePayload()'s transaction.data
|
object
args:
TransactionArgument[]
humanReadable:
AnyJson
tag:
TxTag
getEventByIndexedArgs(
opts):Promise<EventIdentifier|null>
Defined in: api/client/Network.ts:235
Retrieve a single event by any of its indexed arguments. Can be filtered using parameters
| Parameter | Type | Description |
|---|---|---|
opts |
{ eventArg0?: string; eventArg1?: string; eventArg2?: string; eventId: EventIdEnum; moduleId: ModuleIdEnum; } |
- |
opts.eventArg0? |
string |
event parameter value to filter by in position 0 |
opts.eventArg1? |
string |
event parameter value to filter by in position 1 |
opts.eventArg2? |
string |
event parameter value to filter by in position 2 |
opts.eventId |
EventIdEnum |
type of the event to fetch |
opts.moduleId |
ModuleIdEnum |
type of the module to fetch |
Promise<EventIdentifier | null>
uses the middlewareV2
getEventsByIndexedArgs(
opts):Promise<EventIdentifier[] |null>
Defined in: api/client/Network.ts:598
Retrieve a list of events. Can be filtered using parameters
| Parameter | Type |
|---|---|
opts |
MiddlewarePaginationOptions & object
|
Promise<EventIdentifier[] | null>
uses the middlewareV2
getLatestBlock():
Promise<BigNumber>
Defined in: api/client/Network.ts:74
Retrieve the number of the latest finalized block in the chain
Promise<BigNumber>
getMiddlewareLag():
Promise<BigNumber>
Defined in: api/client/Network.ts:754
Get the number of blocks the middleware needs to process to be synced with chain. The lag can be around somewhere upto 15 blocks, but this can increase if the block size being processed by the Middleware is too large. If the lag is too large, its recommended to check the indexer health to make sure the Middleware is processing the blocks.
Promise<BigNumber>
uses the middleware V2
getMiddlewareMetadata():
Promise<MiddlewareMetadata|null>
Defined in: api/client/Network.ts:743
Retrieve middleware metadata. Returns null if middleware is disabled
Promise<MiddlewareMetadata | null>
uses the middleware V2
getNetworkProperties():
Promise<NetworkProperties>
Defined in: api/client/Network.ts:95
Retrieve information for the current network
Promise<NetworkProperties>
getProtocolFees(
args):Promise<ProtocolFees[]>
Defined in: api/client/Network.ts:121
Retrieve the protocol fees associated with running specific transactions
| Parameter | Type | Description |
|---|---|---|
args |
{ tags: TxTag[]; } |
- |
args.tags |
TxTag[] |
list of transaction tags (e.g. [TxTags.asset.CreateAsset, TxTags.asset.RegisterUniqueTicker] or ["asset.createAsset", "asset.registerTicker"]) |
Promise<ProtocolFees[]>
getSs58Format():
BigNumber
Defined in: api/client/Network.ts:88
Retrieve the chain's SS58 format
BigNumber
getTotalIssuance():
Promise<BigNumber>
Defined in: api/client/Network.ts:181
Get the total POLYX in existence
Promise<BigNumber>
Promise that resolves to the current total issuance
this is every POLYX the chain has issued, not the circulating or staked amount. It is the denominator for a staking ratio, and one of the inputs to Polymesh's inflation curve — see staking.getConstants
getTotalIssuance(
callback):Promise<UnsubCallback>
Defined in: api/client/Network.ts:192
Get the total POLYX in existence (with subscription support)
| Parameter | Type | Description |
|---|---|---|
callback |
SubCallback<BigNumber> |
Callback function that receives issuance updates |
Promise<UnsubCallback>
Promise that resolves to an unsubscribe function
can be subscribed to, if connected to node using a web socket
getTransactionByHash(
opts):Promise<ExtrinsicDataWithFees|null>
Defined in: api/client/Network.ts:648
Retrieve a transaction by hash
| Parameter | Type | Description |
|---|---|---|
opts |
{ txHash: string; } |
- |
opts.txHash |
string |
hash of the transaction |
Promise<ExtrinsicDataWithFees | null>
uses the middlewareV2
getTreasuryAccount():
Account
Defined in: api/client/Network.ts:128
Get the treasury wallet address
getTreasuryBalance():
Promise<BigNumber>
Defined in: api/client/Network.ts:141
Get the Treasury POLYX balance
Promise<BigNumber>
Promise that resolves to the current Treasury balance
getTreasuryBalance(
callback):Promise<UnsubCallback>
Defined in: api/client/Network.ts:152
Get the Treasury POLYX balance (with subscription support)
| Parameter | Type | Description |
|---|---|---|
callback |
SubCallback<BigNumber> |
Callback function that receives balance updates |
Promise<UnsubCallback>
Promise that resolves to an unsubscribe function
can be subscribed to, if connected to node using a web socket
getVersion():
Promise<string>
Defined in: api/client/Network.ts:81
Fetch the current network version (e.g. 3.1.0)
Promise<string>
submitEthTransaction(
rawSignedTx,opts?):Promise<SubmissionDetails>
Defined in: api/client/Network.ts:344
Submits a raw, signed Ethereum transaction that carries a Polymesh runtime call through the
revive pallet's sentinel address. This is the SDK-broadcast submission step, reused
here to unlock Fireblocks / KMS / HSM / air-gapped custody flows for Ethereum-derived
Accounts: build the payload via
transaction.toEthSignablePayload,
sign it externally, and submit the raw signed bytes here
| Parameter | Type | Description |
|---|---|---|
rawSignedTx |
`0x${string}` |
the raw signed Ethereum transaction, as returned by an EthSigner's signTransaction
|
opts |
SubmissionOpts |
bounds on how long to wait while broadcasting and tracking the transaction. Defaults to waiting indefinitely |
Promise<SubmissionDetails>
TransactionTimeout if a bound in opts is exceeded. The transaction is not cancelled
by this, and can be tracked afterwards with watchTransaction
submitTransaction(
txPayload,signature,opts?):Promise<SubmissionDetails>
Defined in: api/client/Network.ts:278
Submits a transaction payload with its signature to the chain. signature should be hex encoded
| Parameter | Type | Description |
|---|---|---|
txPayload |
TransactionPayloadInput |
- |
signature |
string |
- |
opts |
SubmissionOpts |
bounds on how long to wait while broadcasting and tracking the transaction. Defaults to waiting indefinitely |
Promise<SubmissionDetails>
if the signature is not hex encoded
TransactionTimeout if a bound in opts is exceeded. The transaction is not cancelled
by this, and can be tracked afterwards with watchTransaction
supportsConfidentialAssets():
boolean
Defined in: api/client/Network.ts:771
Returns whether or not the connected chain node as support for confidential assets
boolean
supportsSubscription():
boolean
Defined in: api/client/Network.ts:787
Returns if functions can be subscribed.
boolean
true if connected over ws(s)://, otherwise false
transferPolyx(
args,opts?):Promise<GenericPolymeshTransaction<void,void>>
Defined in: api/client/Network.ts:222
Transfer an amount of POLYX to a specified Account
| Parameter | Type |
|---|---|
args |
TransferPolyxParams |
opts? |
ProcedureOpts |
Promise<GenericPolymeshTransaction<void, void>>
this method is of type ProcedureMethod, which means you can call transferPolyx.checkAuthorization on it to see whether the signing Account and Identity have the required roles and permissions to run it
watchTransaction(
args):Promise<SubmissionDetails>
Defined in: api/client/Network.ts:378
Track a transaction that has already been broadcast, by its hash, and wait for it to be included in a finalized block
Complements transaction.broadcast and the timeouts on submitTransaction / submitEthTransaction: each of those can leave a transaction in flight but untracked. Since this needs nothing but a hash and a block height, tracking can be picked back up in a later session — after a page reload, for instance, where the original handle no longer exists
| Parameter | Type | Description |
|---|---|---|
args |
{ isEthTxHash?: boolean; startingBlock: BigNumber; timeout?: number; txHash: string; } |
- |
args.isEthTxHash? |
boolean |
set to true when txHash is an Ethereum transaction hash, i.e. the transaction was broadcast by an Ethereum wallet. Those are carried on chain as an unsigned revive.ethTransact extrinsic, so they are matched by their payload rather than by the extrinsic hash |
args.startingBlock |
BigNumber |
block height to start searching from. This must be at or before the block the transaction was submitted in, or it will not be found. broadcast returns the correct value to persist |
args.timeout? |
number |
milliseconds to wait before giving up. Defaults to waiting indefinitely |
args.txHash |
string |
hash of the transaction to look for |
Promise<SubmissionDetails>
TransactionTimeout if the transaction is not found in time. It may still be included
afterwards — this reports only that the search stopped