404
How did we get here?Take me home.
diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index e5a675eddd..0000000000 --- a/docs/404.html +++ /dev/null @@ -1,17 +0,0 @@ - - -
- - -Individuals making significant and valuable contributions are given commit-access to a project to contribute as they see fit. -A project is more like an open wiki than a standard guarded open source project.
There are a few basic ground-rules for contributors (including the maintainer(s) of the project):
--force pushes or modifying the Git history in any way. If you need to rebase, ensure you do it in your own repo.<initials>-<feature>) must be used for ongoing work.When reviewing a pull request, the end-goal is to suggest useful changes to the author. Reviews should finish with approval unless there are issues that would result in:
Declaring formal releases remains the prerogative of the project maintainer(s).
This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
These contributing guidelines are modified from the "OPEN Open Source Project" guidelines for the Level project: https://github.com/Level/community/blob/master/CONTRIBUTING.md
- ← - - @polkadot/types -
Events are emitted for certain operations on the runtime. The following sections describe the events that are part of the default Substrate runtime.
▸ NewAccount(AccountId, Balance)
▸ ReapedAccount(AccountId)
▸ Transfer(AccountId, AccountId, Balance, Balance)
▸ CodeStored(Hash)
▸ Dispatched(AccountId, bool)
▸ Instantiated(AccountId, AccountId)
▸ ScheduleUpdated(u32)
▸ Transfer(AccountId, AccountId, Balance)
from -> to with given value as part of a message-call or create.▸ BadReaperSlashed(AccountId)
▸ TallyFinalised(Vec<AccountId>, Vec<AccountId>)
▸ TallyStarted(u32)
▸ VoterReaped(AccountId, AccountId)
▸ Approved(Hash)
▸ Disapproved(Hash)
▸ Executed(Hash, bool)
bool is true if returned without error.▸ Proposed(AccountId, ProposalIndex, Hash, u32)
▸ Voted(AccountId, Hash, bool, u32, u32)
▸ TallyCancelation(Hash, u32, u32, u32)
▸ TallyReferendum(Hash, u32, u32, u32)
▸ Cancelled(ReferendumIndex)
▸ Executed(ReferendumIndex, bool)
▸ NotPassed(ReferendumIndex)
▸ Passed(ReferendumIndex)
▸ Proposed(PropIndex, Balance)
▸ Started(ReferendumIndex, VoteThreshold)
▸ Tabled(PropIndex, Balance, Vec<AccountId>)
▸ Charged(u32, Amount)
▸ NewAuthorities(Vec<(SessionKey,u64)>)
▸ NewAccountIndex(AccountId, AccountIndex)
AccountId.▸ NewSession(BlockNumber)
▸ OfflineSlash(AccountId, Balance)
▸ OfflineWarning(AccountId, u32)
▸ Reward(Balance)
▸ KeyChanged(AccountId)
▸ Sudid(bool)
▸ ExtrinsicFailed()
▸ ExtrinsicSuccess()
▸ Awarded(ProposalIndex, Balance, AccountId)
▸ Burnt(Balance)
▸ Proposed(ProposalIndex)
▸ Rollover(Balance)
▸ Spending(Balance)
- ← - - Extrinsics (defaults) - - @polkadot/api - - → -
The following sections contain Extrinsics methods are part of the default Substrate runtime.
▸ setBalance(who: Address, free: Compact<Balance>, reserved: Compact<Balance>)
▸ transfer(dest: Address, value: Compact<Balance>)
▸ noteOffline(offline: InherentOfflineReport)
▸ remark(_remark: Bytes)
▸ reportMisbehavior(_report: Bytes)
▸ setCode(new: Bytes)
▸ setHeapPages(pages: u64)
▸ setStorage(items: Vec<KeyValue>)
▸ call(dest: Address, value: Compact<Balance>, gas_limit: Compact<Gas>, data: Bytes)
▸ create(endowment: Compact<Balance>, gas_limit: Compact<Gas>, code_hash: CodeHash, data: Bytes)
ctor_code is executed in the context of the newly created account. Buffer returned after the execution is saved as the code of the account. That code will be invoked upon any message received by this account.▸ putCode(gas_limit: Compact<Gas>, code: Bytes)
▸ updateSchedule(schedule: Schedule)
▸ presentWinner(candidate: Address, total: Compact<BalanceOf>, index: Compact<VoteIndex>)
signed is one of the top Self::carry_count() + current_vote().1 candidates. Only works if the block_number >= current_vote().0 and < current_vote().0 + presentation_duration()``signed` should have at least▸ reapInactiveVoter(reporter_index: Compact<u32>, who: Address, who_index: Compact<u32>, assumed_vote_index: Compact<VoteIndex>)
signed.▸ removeMember(who: Address)
▸ retractVoter(index: Compact<u32>)
▸ setApprovals(votes: Vec<bool>, index: Compact<VoteIndex>)
▸ setDesiredSeats(count: Compact<u32>)
▸ setPresentationDuration(count: Compact<BlockNumber>)
finalise_vote.▸ setTermDuration(count: Compact<BlockNumber>)
finalise_vote.▸ submitCandidacy(slot: Compact<u32>)
▸ propose(threshold: Compact<u32>, proposal: Proposal)
▸ vote(proposal: Hash, index: Compact<ProposalIndex>, approve: bool)
▸ propose(proposal: Proposal)
▸ setCooloffPeriod(blocks: Compact<BlockNumber>)
▸ setVotingPeriod(blocks: Compact<BlockNumber>)
▸ veto(proposal_hash: Hash)
▸ vote(proposal: Hash, approve: bool)
▸ cancelQueued(when: Compact<BlockNumber>, which: Compact<u32>)
▸ cancelReferendum(ref_index: Compact<ReferendumIndex>)
▸ propose(proposal: Proposal, value: Compact<BalanceOf>)
▸ second(proposal: Compact<PropIndex>)
▸ startReferendum(proposal: Proposal, threshold: VoteThreshold, delay: BlockNumber)
▸ vote(ref_index: Compact<ReferendumIndex>, vote: Vote)
vote.is_aye(), the vote is to enact the proposal; otherwise it is a vote to keep the status quo.▸ reportMisbehavior(_report: Bytes)
▸ forceNewSession(apply_rewards: bool)
▸ setKey(key: SessionKey)
_validator to _key. This doesn't take effect until the next session.▸ setLength(new: Compact<BlockNumber>)
▸ forceNewEra(apply_rewards: bool)
apply_rewards should be true for validators to get the session reward.▸ nominate(target: Address)
▸ registerPreferences(intentions_index: Compact<u32>, prefs: ValidatorPrefs)
Self::intentions()[intentions_index] != origin.▸ setBondingDuration(new: Compact<BlockNumber>)
▸ setInvulnerables(validators: Vec<AccountId>)
▸ setOfflineSlashGrace(new: Compact<u32>)
▸ setSessionsPerEra(new: Compact<BlockNumber>)
▸ setValidatorCount(new: Compact<u32>)
▸ stake()
▸ unnominate(target_index: Compact<u32>)
▸ unstake(intentions_index: Compact<u32>)
▸ setKey(new: Address)
▸ sudo(proposal: Proposal)
▸ set(now: Compact<Moment>)
block_period.▸ approveProposal(proposal_id: Compact<ProposalIndex>)
▸ configure(proposal_bond: Compact<Permill>, proposal_bond_minimum: Compact<BalanceOf>, spend_period: Compact<BlockNumber>, burn: Compact<Permill>)
▸ proposeSpend(value: Compact<BalanceOf>, beneficiary: Address)
▸ rejectProposal(proposal_id: Compact<ProposalIndex>)
▸ setPot(new_pot: Compact<BalanceOf>)
The following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit. The RPCs are provided by Substrate itself.
Authoring of network items
▸ pendingExtrinsics(): PendingExtrinsics
▸ submitAndWatchExtrinsic(extrinsic: Extrinsic): ExtrinsicStatus
▸ submitExtrinsic(extrinsic: Extrinsic): Hash
Retrieval of chain data
▸ getBlock(hash?: Hash): SignedBlock
▸ getBlockHash(blockNumber?: BlockNumber): Hash
▸ getFinalisedHead(): Hash
▸ getHeader(hash?: Hash): Header
▸ getRuntimeVersion(hash?: Hash): RuntimeVersion
▸ subscribeFinalisedHeads(): Header
▸ subscribeNewHead(): Header
▸ subscribeRuntimeVersion(): RuntimeVersion
Query of state
▸ call(method: Text, data: Bytes, block?: Hash): Bytes
▸ getMetadata(block?: Hash): Metadata
▸ getRuntimeVersion(hash?: Hash): RuntimeVersion
▸ getStorage(key: StorageKey, block?: Hash): StorageData
▸ getStorageHash(key: StorageKey, block?: Hash): Hash
▸ getStorageSize(key: StorageKey, block?: Hash): u64
▸ queryStorage(keys: Vec<StorageKey>, startBlock: Hash, block?: Hash): Vec<StorageChangeSet>
▸ subscribeStorage(keys: Vec<StorageKey>): StorageChangeSet
Methods to retrieve system info
▸ chain(): Text
▸ health(): Health
▸ name(): Text
▸ networkState(): NetworkState
▸ peers(): Vec<PeerInfo>
▸ properties(): ChainProperties
▸ version(): Text
- ← - - Upgrade via sudo - - State storage (defaults) - - → -
The following sections contain Storage methods are part of the default Substrate runtime.
▸ creationFee(): Balance
▸ existentialDeposit(): Balance
▸ freeBalance(AccountId): Balance
ExistentialDeposit, then the 'current account' is deleted: specifically FreeBalance. Furthermore, OnFreeBalanceZero callback is invoked, giving a chance to external modules to cleanup data associated with the deleted account. system::AccountNonce is also deleted if ReservedBalance is also zero (it also gets collapsed to zero if it ever becomes less than ExistentialDeposit.▸ reservedBalance(AccountId): Balance
Bondage system used in the staking module.) When this balance falls below the value of ExistentialDeposit, then this 'reserve account' is deleted: specifically, ReservedBalance. system::AccountNonce is also deleted if FreeBalance is also zero (it also gets collapsed to zero if it ever becomes less than ExistentialDeposit.▸ totalIssuance(): Balance
▸ transferFee(): Balance
▸ vesting(AccountId): Option<VestingSchedule>
▸ originalAuthorities(): Option<Vec<SessionKey>>
▸ blockGasLimit(): Gas
▸ callBaseFee(): Gas
▸ codeHashOf(AccountId): Option<CodeHash>
▸ codeStorage(CodeHash): Option<PrefabWasmModule>
▸ contractFee(): Balance
▸ createBaseFee(): Gas
▸ currentSchedule(): Schedule
▸ gasPrice(): Balance
▸ gasSpent(): Gas
▸ maxDepth(): u32
▸ pristineCode(CodeHash): Option<Bytes>
▸ activeCouncil(): Vec<(AccountId,BlockNumber)>
▸ approvalsOf(AccountId): Vec<bool>
▸ candidacyBond(): BalanceOf
▸ candidateCount(): u32
▸ candidates(): Vec<AccountId>
▸ carryCount(): u32
▸ desiredSeats(): u32
▸ inactiveGracePeriod(): VoteIndex
▸ lastActiveOf(AccountId): Option<VoteIndex>
▸ leaderboard(): Option<Vec<(BalanceOf,AccountId)>>
▸ nextFinalise(): Option<(BlockNumber,u32,Vec<AccountId>)>
▸ presentSlashPerVoter(): BalanceOf
▸ presentationDuration(): BlockNumber
▸ registerInfoOf(AccountId): Option<(VoteIndex,u32)>
who was registered or None if they are not currently registered.▸ snapshotedStakes(): Vec<BalanceOf>
▸ termDuration(): BlockNumber
▸ voteCount(): VoteIndex
▸ voters(): Vec<AccountId>
▸ votingBond(): BalanceOf
▸ votingPeriod(): BlockNumber
▸ proposalCount(): u32
▸ proposalOf(Hash): Option<Proposal>
▸ proposals(): Vec<Hash>
▸ voting(Hash): Option<(ProposalIndex,u32,Vec<AccountId>,Vec<AccountId>)>
▸ cooloffPeriod(): BlockNumber
▸ councilVoteOf((Hash,AccountId)): Option<bool>
▸ enactDelayPeriod(): BlockNumber
▸ proposalOf(Hash): Option<Proposal>
▸ proposalVoters(Hash): Vec<AccountId>
▸ proposals(): Vec<(BlockNumber,Hash)>
▸ vetoedProposal(Hash): Option<(BlockNumber,Vec<AccountId>)>
▸ votingPeriod(): BlockNumber
▸ bondage(AccountId): BlockNumber
who's funds become liquid.▸ depositOf(PropIndex): Option<(BalanceOf,Vec<AccountId>)>
▸ dispatchQueue(BlockNumber): Vec<Option<(Proposal,ReferendumIndex)>>
▸ launchPeriod(): BlockNumber
▸ maxLockPeriods(): LockPeriods
PublicDelay.▸ minimumDeposit(): BalanceOf
▸ nextTally(): ReferendumIndex
▸ publicDelay(): BlockNumber
▸ publicPropCount(): PropIndex
▸ publicProps(): Vec<(PropIndex,Proposal,AccountId)>
▸ referendumCount(): ReferendumIndex
▸ referendumInfoOf(ReferendumIndex): Option<ReferendumInfo>
▸ voteOf((ReferendumIndex,AccountId)): Vote
voters_for includes the voter when called with the referendum (you'll get the default Vote value otherwise). If you don't want to check voters_for, then you can also check for simple existence with VoteOf::exists first.▸ votersFor(ReferendumIndex): Vec<AccountId>
▸ votingPeriod(): BlockNumber
▸ currentTransactionFee(u32): AssetOf
extrinsic_index => accumulated_fees map, containing records to track the overall charged fees for each transaction. All records should be removed at finalise stage.▸ transactionBaseFee(): AssetOf
▸ transactionByteFee(): AssetOf
▸ pendingChange(): Option<StoredPendingChange>
▸ enumSet(AccountIndex): Vec<AccountId>
▸ nextEnumSet(): AccountIndex
▸ currentIndex(): BlockNumber
▸ currentStart(): Moment
▸ forcingNewSession(): Option<bool>
▸ lastLengthChange(): Option<BlockNumber>
▸ nextKeyFor(AccountId): Option<SessionKey>
▸ nextSessionLength(): Option<BlockNumber>
▸ sessionLength(): BlockNumber
▸ validators(): Vec<AccountId>
▸ bondage(AccountId): BlockNumber
who's funds become entirely liquid.▸ bondingDuration(): BlockNumber
▸ currentEra(): BlockNumber
▸ currentNominatorsFor(AccountId): Vec<AccountId>
▸ currentOfflineSlash(): BalanceOf
▸ currentSessionReward(): BalanceOf
▸ forcingNewEra(): Option<Null>
▸ intentions(): Vec<AccountId>
▸ invulerables(): Vec<AccountId>
▸ lastEraLengthChange(): BlockNumber
▸ minimumValidatorCount(): u32
▸ nextSessionsPerEra(): Option<BlockNumber>
▸ nominating(AccountId): Option<AccountId>
▸ nominatorsFor(AccountId): Vec<AccountId>
▸ offlineSlash(): Perbill
▸ offlineSlashGrace(): u32
▸ recentlyOffline(): Vec<(AccountId,BlockNumber,u32)>
RECENT_OFFLINE_COUNT instances. (who it was, when it was reported, how many instances they were offline for).▸ sessionReward(): Perbill
▸ sessionsPerEra(): BlockNumber
▸ slashCount(AccountId): u32
▸ stakeRange(): (BalanceOf,BalanceOf)
▸ validatorCount(): u32
▸ validatorPreferences(AccountId): ValidatorPrefs
▸ key(): AccountId
▸ accountNonce(AccountId): Index
▸ allExtrinsicsLen(): Option<u32>
▸ blockHash(BlockNumber): Hash
▸ digest(): Digest
▸ events(): Vec<EventRecord>
▸ extrinsicCount(): Option<u32>
▸ extrinsicData(u32): Bytes
▸ extrinsicsRoot(): Hash
▸ number(): BlockNumber
execute_block.▸ parentHash(): Hash
▸ randomSeed(): Hash
▸ blockPeriod(): Moment
▸ didUpdate(): bool
▸ now(): Moment
▸ approvals(): Vec<ProposalIndex>
▸ burn(): Permill
▸ pot(): BalanceOf
▸ proposalBond(): Permill
▸ proposalBondMinimum(): BalanceOf
▸ proposalCount(): ProposalIndex
▸ proposals(ProposalIndex): Option<Proposal>
▸ spendPeriod(): BlockNumber
These are keys that are always available to the runtime implementation
▸ authorityCount(): u32
▸ authorityPrefix(): u32
▸ changesTrieConfig(): u32
▸ code(): Bytes
▸ extrinsicIndex(): u32
▸ heapPages(): u64
- ← - - Substrate RPC - - Extrinsics (defaults) - - → -
name: ReferendumInfoExtended
description: A [[ReferendumInfo]] with an additional index field
ConstructorDefobjectobjectobjectReferendumInfo
↳ ReferendumInfoExtended
Codec⊕ new ReferendumInfoExtended(value: ReferendumInfo | ReferendumInfoExtended, index?: BN | number): ReferendumInfoExtended
Overrides ReferendumInfo.__constructor
Defined in democracy/referendumInfo.ts:20
Parameters:
| Name | Type |
|---|---|
| value | ReferendumInfo | ReferendumInfoExtended |
Optional index | BN | number |
Returns: ReferendumInfoExtended
● __@toStringTag: string
Inherited from Map.[Symbol.toStringTag]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:130
● size: number
Inherited from Map.size
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get Type(): E
Inherited from Struct.Type
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:160
description: Returns the Type description to sthe structure
Returns: E
get delay(): BlockNumber
Inherited from ReferendumInfo.delay
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/ReferendumInfo.ts:58
description: The delay (in blocks) to wait after a successful referendum before deploying
Returns: BlockNumber
get encodedLength(): number
Inherited from Struct.encodedLength
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:167
description: The length of the value when encoded as a Uint8Array
Returns: number
get end(): BlockNumber
Inherited from ReferendumInfo.end
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/ReferendumInfo.ts:37
description: When voting on this referendum will end
Returns: BlockNumber
get index(): ReferendumIndex
Defined in democracy/referendumInfo.ts:33
description: Convenience getter, returns the referendumIndex
Returns: ReferendumIndex
get isEmpty(): boolean
Inherited from Struct.isEmpty
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:145
description: Checks if the value is an empty value
Returns: boolean
get proposal(): Proposal
Inherited from ReferendumInfo.proposal
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/ReferendumInfo.ts:44
description: The proposal being voted on
Returns: Proposal
get threshold(): VoteThreshold
Inherited from ReferendumInfo.threshold
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/ReferendumInfo.ts:51
description: The thresholding mechanism to determine whether it passed
Returns: VoteThreshold
▸ __@iterator(): IterableIterator<[keyof S, Codec]>
Inherited from Map.[Symbol.iterator]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:113
Returns an iterable of entries in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ clear(): void
Inherited from Map.clear
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:22
Returns: void
▸ delete(key: keyof S): boolean
Inherited from Map.delete
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:23
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ entries(): IterableIterator<[keyof S, Codec]>
Inherited from Map.entries
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:118
Returns an iterable of key, value pairs for every entry in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ eq(other?: any): boolean
Inherited from Struct.eq
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:176
description: Compares the value of the input to see if there is a match
Parameters:
| Name | Type |
|---|---|
Optional other | any |
Returns: boolean
▸ forEach(callbackfn: function, thisArg?: any): void
Inherited from Map.forEach
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
Parameters:
| Name | Type |
|---|---|
| callbackfn | function |
Optional thisArg | any |
Returns: void
▸ get(name: keyof S): Codec | undefined
Inherited from Struct.get
Overrides Map.get
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:184
description: Returns a specific names entry in the structure
Parameters:
| Name | Type | Description |
|---|---|---|
| name | keyof S | The name of the entry to retrieve |
Returns: Codec | undefined
▸ getAtIndex(index: number): Codec
Inherited from Struct.getAtIndex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:191
description: Returns the values of a member at a specific index (Rather use get(name) for performance)
Parameters:
| Name | Type |
|---|---|
| index | number |
Returns: Codec
▸ has(key: keyof S): boolean
Inherited from Map.has
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:26
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ keys(): IterableIterator<keyof S>
Inherited from Map.keys
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:123
Returns an iterable of keys in the map
Returns: IterableIterator<keyof S>
▸ set(key: keyof S, value: Codec): this
Inherited from Map.set
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:27
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
| value | Codec |
Returns: this
▸ toArray(): Array<Codec>
Inherited from Struct.toArray
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:198
description: Converts the Object to an standard JavaScript Array
Returns: Array<Codec>
▸ toHex(): string
Inherited from Struct.toHex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:205
description: Returns a hex string representation of the value
Returns: string
▸ toJSON(): any
Overrides Struct.toJSON
Defined in democracy/referendumInfo.ts:40
description: Creates the JSON representation
Returns: any
▸ toString(): string
Inherited from Struct.toString
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:226
description: Returns the string representation of the value
Returns: string
▸ toU8a(isBare?: undefined | false | true): Uint8Array
Inherited from Struct.toU8a
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:234
description: Encodes the value as a Uint8Array as per the parity-codec specifications
Parameters:
| Name | Type | Description |
|---|---|---|
Optional isBare | undefined | false | true | true when the value has none of the type-specific prefixes (internal) |
Returns: Uint8Array
▸ values(): IterableIterator<Codec>
Inherited from Map.values
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:128
Returns an iterable of values in the map
Returns: IterableIterator<Codec>
<Static> with▸ with<S>(Types: S): Constructor<Struct<S>>
Inherited from Struct.with
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:125
Type parameters:
ConstructorDefParameters:
| Name | Type |
|---|---|
| Types | S |
Returns: Constructor<Struct<S>>
Common functions used across Polkadot, derived from RPC calls and storage queries.
Ƭ AccountIdAndIndex: [undefined | AccountId, undefined | AccountIndex]
Defined in accounts/idAndIndex.ts:16
▸ idAndIndex(api: ApiInterface$Rx): (Anonymous function)
Defined in accounts/idAndIndex.ts:18
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ idToIndex(api: ApiInterface$Rx): (Anonymous function)
Defined in accounts/idToIndex.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
Ƭ AccountIndexes: object
Defined in accounts/indexes.ts:13
▸ indexes(api: ApiInterface$Rx): (Anonymous function)
Defined in accounts/indexes.ts:15
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ indexToId(api: ApiInterface$Rx): (Anonymous function)
Defined in accounts/indexToId.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ fees(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/fees.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ validatingBalance(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/validatingBalance.ts:16
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ validatingBalances(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/validatingBalances.ts:14
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ votingBalance(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/votingBalance.ts:16
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ votingBalances(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/votingBalances.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ votingBalancesNominatorsFor(api: ApiInterface$Rx): (Anonymous function)
Defined in balances/votingBalancesNominatorsFor.ts:15
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ bestNumber(api: ApiInterface$Rx): (Anonymous function)
Defined in chain/bestNumber.ts:23
description: Get the latest block number.
example:
api.derive.chain.bestNumber((blockNumber) => {
- console.log(`the current best block is #${blockNumber}`);
-});
- Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ bestNumberFinalised(api: ApiInterface$Rx): (Anonymous function)
Defined in chain/bestNumberFinalised.ts:23
description: Get the latest finalised block number. example
api.derive.chain.bestNumberFinalised((blockNumber) => {
- console.log(`the current finalised block is #${blockNumber}`);
-});
- Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ bestNumberLag(api: ApiInterface$Rx): (Anonymous function)
Defined in chain/bestNumberLag.ts:25
description: Calculates the lag between finalised head and best head
example:
api.derive.chain.bestNumberLag((lag) => {
- console.log(`finalised is ${lag} blocks behind head`);
-});
- Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ getHeader(api: ApiInterface$Rx): (Anonymous function)
Defined in chain/getHeader.ts:25
description: Get the a specific block header and extend it with the author
example:
const { author, blockNumber } = await api.derive.chain.getHeader('0x123...456');
-
-console.log(`block #${blockNumber} was authored by ${author}`);
- Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
Ƭ HeaderAndValidators: [Header, Array<AccountId>]
Defined in chain/subscribeNewHead.ts:12
▸ subscribeNewHead(api: ApiInterface$Rx): (Anonymous function)
Defined in chain/subscribeNewHead.ts:25
description: Subscribe to block headers and extend it with the author
example:
api.derive.chain.subscribeNewHead(({ author, blockNumber }) => {
- console.log(`block #${blockNumber} was authored by ${author}`);
-});
- Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ referendumInfo(api: ApiInterface$Rx): (Anonymous function)
Defined in democracy/referendumInfo.ts:48
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ referendumInfos(api: ApiInterface$Rx): (Anonymous function)
Defined in democracy/referendumInfos.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ referendums(api: ApiInterface$Rx): (Anonymous function)
Defined in democracy/referendums.ts:14
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ referendumVotesFor(api: ApiInterface$Rx): (Anonymous function)
Defined in democracy/referendumVotesFor.ts:16
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ votes(api: ApiInterface$Rx): (Anonymous function)
Defined in democracy/votes.ts:12
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ eraLength(api: ApiInterface$Rx): (Anonymous function)
Defined in session/eraLength.ts:13
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ eraProgress(api: ApiInterface$Rx): (Anonymous function)
Defined in session/eraProgress.ts:14
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ sessionProgress(api: ApiInterface$Rx): (Anonymous function)
Defined in session/sessionProgress.ts:14
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
▸ intentionsBalances(api: ApiInterface$Rx): (Anonymous function)
Defined in staking/intentionsBalances.ts:17
Get the balances for all intentions and their nominators
Parameters:
| Name | Type |
|---|---|
| api | ApiInterface$Rx |
Returns: (Anonymous function)
Ƭ DerivedBalances: object
Defined in types.ts:8
Ƭ DerivedBalancesMap: object
Defined in types.ts:26
Ƭ DerivedFees: object
Defined in types.ts:18
Ƭ DerivedReferendumVote: object
Defined in types.ts:30
<Const> cache▸ cache(fn: Function, map?: WeakMap<object, any>): (Anonymous function)
Defined in util/cache.ts:23
Create memoization for a 2-currified function.
Parameters:
| Name | Type | Default value | Description |
|---|---|---|---|
| fn | Function | - | The function to memoize. |
Default value map | WeakMap<object, any> | new WeakMap() | The Map used to cache function returns. |
Returns: (Anonymous function)
ApiBase
↳ ApiRx
CodecResult, SubscriptionResult>⊕ new ApiBase(provider?: ApiOptions | ProviderInterface, type: ApiType): ApiBase
Defined in Base.ts:81
description: Create an instance of the class
example:
import Api from '@polkadot/api/promise';
-
-const api = new Api().isReady();
-
-api.rpc.subscribeNewHead((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
-});
- Parameters:
| Name | Type | Default value |
|---|---|---|
Default value provider | ApiOptions | ProviderInterface | {} |
| type | ApiType | - |
Returns: ApiBase
get derive(): Derive<CodecResult, SubscriptionResult>
Defined in Base.ts:196
description: Derived results that are injected into the API, allowing for combinations of various query results.
example:
api.derive.chain.bestNumber((number) => {
- console.log('best number', number);
-});
- Returns: Derive<CodecResult, SubscriptionResult>
get genesisHash(): Hash
Defined in Base.ts:132
description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
Returns: Hash
get hasSubscriptions(): boolean
Defined in Base.ts:141
description: true when subscriptions are supported
Returns: boolean
get libraryInfo(): string
Defined in Base.ts:148
description: The library information name & version (from package.json)
Returns: string
get query(): QueryableStorage<CodecResult, SubscriptionResult>
Defined in Base.ts:216
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.
example:
api.query.balances.freeBalance(<accountId>, (balance) => {
- console.log('new balance', balance);
-});
- Returns: QueryableStorage<CodecResult, SubscriptionResult>
get rpc(): DecoratedRpc<CodecResult, SubscriptionResult>
Defined in Base.ts:236
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (usine known keys) and the submission of transactions.
example:
api.rpc.chain.subscribeNewHead((header) => {
- console.log('new header', header);
-});
- Returns: DecoratedRpc<CodecResult, SubscriptionResult>
get runtimeMetadata(): Metadata
Defined in Base.ts:155
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: Metadata
get runtimeVersion(): RuntimeVersion
Defined in Base.ts:164
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
get tx(): SubmittableExtrinsics<CodecResult, SubscriptionResult>
Defined in Base.ts:254
description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
example:
api.tx.balances
- .transfer(<recipientId>, <balance>)
- .signAndSend(<keyPair>, ({status}) => {
- console.log('tx status', status.asFinalised.toHex());
- });
- Returns: SubmittableExtrinsics<CodecResult, SubscriptionResult>
get type(): ApiType
Defined in Base.ts:173
description: The type of this API instance, either 'rxjs' or 'promise'
Returns: ApiType
▸ disconnect(): void
Defined in Base.ts:263
description: Disconnect from the underlying provider, halting all comms
Returns: void
▸ on(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:286
description: Attach an eventemitter handler to listen to a specific event
example:
api.on('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.on('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ once(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:311
description: Attach an one-time eventemitter handler to listen to a specific event
example:
api.once('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.once('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ registerTypes(types?: RegistryTypes): void
Defined in Base.ts:320
description: Register additional user-defined of chain-specific types in the type registry
Parameters:
| Name | Type |
|---|---|
Optional types | RegistryTypes |
Returns: void
▸ setSigner(signer: Signer): void
Defined in Base.ts:180
description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
Parameters:
| Name | Type |
|---|---|
| signer | Signer |
Returns: void
name: ApiPromise
description: ApiPromise is a standard JavaScript wrapper around the RPC and interfaces on the Polkadot network. As a full Promise-based, all interface calls return Promises, including the static .create(...). Subscription calls utilise (value) => {} callbacks to pass through the latest values.
The API is well suited to real-time applications where either the single-shot state is needed or use is to be made of the subscription-based features of Polkadot (and Substrate) clients.
see: ApiRx
Making rpc calls -
import ApiPromise from '@polkadot/api/promise';
-
-// initialise via static create
-const api = await ApiPromise.create();
-
-// make a subscription to the network head
-api.rpc.chain.subscribeNewHead((header) => {
- console.log(`Chain is at #${header.blockNumber}`);
-});
- Subscribing to chain state -
import { ApiPromise, WsProvider } from '@polkadot/api';
-
-// initialise a provider with a specific endpoint
-const provider = new WsProvider('wss://example.com:9944')
-
-// initialise via isReady & new with specific provider
-const api = await new ApiPromise(provider).isReady;
-
-// retrieve the block target time
-const blockPeriod = await api.query.timestamp.blockPeriod().toNumber();
-let last = 0;
-
-// subscribe to the current block timestamp, updates automatically (callback provided)
-api.query.timestamp.now((timestamp) => {
- const elapsed = last
- ? `, ${timestamp.toNumber() - last}s since last`
- : '';
-
- last = timestamp.toNumber();
- console.log(`timestamp ${timestamp}${elapsed} (${blockPeriod}s target)`);
-});
- Submitting a transaction -
import ApiPromise from '@polkadot/api/promise';
-
-ApiPromise.create().then((api) => {
- const nonce = await api.query.system.accountNonce(keyring.alice.address());
-
- api.tx.balances
- // create transfer
- transfer(keyring.bob.address(), 12345)
- // sign the transcation
- .sign(keyring.alice, { nonce })
- // send the transaction (optional status callback)
- .send((status) => {
- console.log(`current status ${status.type}`);
- })
- // retrieve the submitted extrinsic hash
- .then((hash) => {
- console.log(`submitted with hash ${hash}`);
- });
-});
- ApiBase<CodecResult, SubscriptionResult>
↳ ApiPromise
⊕ new ApiPromise(options?: ApiOptions | ProviderInterface): ApiPromise
Overrides ApiBase.constructor
Defined in promise/Api.ts:127
description: Creates an instance of the ApiPromise class
example:
import Api from '@polkadot/api/promise';
-
-new Api().isReady.then((api) => {
- api.rpc.subscribeNewHead((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
- });
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
Optional options | ApiOptions | ProviderInterface | Options to create an instance. This can be either ApiOptions or an [[WsProvider]]. |
Returns: ApiPromise
get derive(): Derive<CodecResult, SubscriptionResult>
Defined in Base.ts:196
description: Derived results that are injected into the API, allowing for combinations of various query results.
example:
api.derive.chain.bestNumber((number) => {
- console.log('best number', number);
-});
- Returns: Derive<CodecResult, SubscriptionResult>
get genesisHash(): Hash
Inherited from ApiBase.genesisHash
Defined in Base.ts:132
description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
Returns: Hash
get hasSubscriptions(): boolean
Inherited from ApiBase.hasSubscriptions
Defined in Base.ts:141
description: true when subscriptions are supported
Returns: boolean
get isReady(): Promise<ApiPromise>
Defined in promise/Api.ts:161
description: Promise that returns the first time we are connected and loaded
Returns: Promise<ApiPromise>
get libraryInfo(): string
Inherited from ApiBase.libraryInfo
Defined in Base.ts:148
description: The library information name & version (from package.json)
Returns: string
get query(): QueryableStorage<CodecResult, SubscriptionResult>
Defined in Base.ts:216
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.
example:
api.query.balances.freeBalance(<accountId>, (balance) => {
- console.log('new balance', balance);
-});
- Returns: QueryableStorage<CodecResult, SubscriptionResult>
get rpc(): DecoratedRpc<CodecResult, SubscriptionResult>
Defined in Base.ts:236
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (usine known keys) and the submission of transactions.
example:
api.rpc.chain.subscribeNewHead((header) => {
- console.log('new header', header);
-});
- Returns: DecoratedRpc<CodecResult, SubscriptionResult>
get runtimeMetadata(): Metadata
Inherited from ApiBase.runtimeMetadata
Defined in Base.ts:155
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: Metadata
get runtimeVersion(): RuntimeVersion
Inherited from ApiBase.runtimeVersion
Defined in Base.ts:164
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
get tx(): SubmittableExtrinsics<CodecResult, SubscriptionResult>
Defined in Base.ts:254
description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
example:
api.tx.balances
- .transfer(<recipientId>, <balance>)
- .signAndSend(<keyPair>, ({status}) => {
- console.log('tx status', status.asFinalised.toHex());
- });
- Returns: SubmittableExtrinsics<CodecResult, SubscriptionResult>
get type(): ApiType
Defined in Base.ts:173
description: The type of this API instance, either 'rxjs' or 'promise'
Returns: ApiType
▸ clone(): ApiPromise
Defined in promise/Api.ts:168
description: Returns a clone of this ApiPromise instance (new underlying provider connection)
Returns: ApiPromise
▸ combineLatest(fns: Array<CombinatorFunction | [CombinatorFunction, Array]>, callback: CombinatorCallback): SubscriptionResult
Defined in promise/Api.ts:195
description: Creates a combinator that can be used to combine the latest results from multiple subscriptions
example:
const address = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFacT7';
-
-// combines values from balance & nonce as it updates
-api.combineLatest([
- api.rpc.chain.subscribeNewHead,
- [api.query.balances.freeBalance, address],
- (cb) => api.query.system.accountNonce(address, cb)
-], ([head, balance, nonce]) => {
- console.log(`#${head.number}: You have ${balance} units, with ${nonce} transactions sent`);
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| fns | Array<CombinatorFunction | [CombinatorFunction, Array]> | An array of function to combine, each in the form of `(cb: (value: void)) => void` |
| callback | CombinatorCallback | A callback that will return an Array of all the values this combinator has been applied to |
Returns: SubscriptionResult
▸ disconnect(): void
Implementation of ApiPromiseInterface.disconnect
Inherited from ApiBase.disconnect
Defined in Base.ts:263
description: Disconnect from the underlying provider, halting all comms
Returns: void
▸ on(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:286
description: Attach an eventemitter handler to listen to a specific event
example:
api.on('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.on('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ once(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:311
description: Attach an one-time eventemitter handler to listen to a specific event
example:
api.once('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.once('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ registerTypes(types?: RegistryTypes): void
Implementation of ApiPromiseInterface.registerTypes
Inherited from ApiBase.registerTypes
Defined in Base.ts:320
description: Register additional user-defined of chain-specific types in the type registry
Parameters:
| Name | Type |
|---|---|
Optional types | RegistryTypes |
Returns: void
▸ setSigner(signer: Signer): void
Implementation of ApiPromiseInterface.setSigner
Inherited from ApiBase.setSigner
Defined in Base.ts:180
description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
Parameters:
| Name | Type |
|---|---|
| signer | Signer |
Returns: void
<Static> create▸ create(options?: ApiOptions | ProviderInterface): Promise<ApiPromise>
Defined in promise/Api.ts:125
description: Creates an ApiPromise instance using the supplied provider. Returns an Promise containing the actual Api instance.
example:
import Api from '@polkadot/api/promise';
-
-Api.create().then(async (api) => {
- const timestamp = await api.query.timestamp.now();
-
- console.log(`lastest block timestamp ${timestamp}`);
-});
- Parameters:
| Name | Type | Default value | Description |
|---|---|---|---|
Default value options | ApiOptions | ProviderInterface | {} | options that is passed to the class contructor. Can be either ApiOptions or a provider (see the constructor arguments) |
Returns: Promise<ApiPromise>
Combinator
⊕ new Combinator(fns: Array<CombinatorFunction | [CombinatorFunction, Array]>, callback: CombinatorCallback): Combinator
Defined in promise/Combinator.ts:21
Parameters:
| Name | Type |
|---|---|
| fns | Array<CombinatorFunction | [CombinatorFunction, Array]> |
| callback | CombinatorCallback |
Returns: Combinator
▸ unsubscribe(): void
Defined in promise/Combinator.ts:67
Returns: void
name: ApiRx
description: ApiRx is a powerfull RxJS Observable wrapper around the RPC and interfaces on the Polkadot network. As a full Observable API, all interface calls return RxJS Observables, including the static .create(...). In the same fashion and subscription-based methods return long-running Observables that update with the latest values.
The API is well suited to real-time applications where the latest state is needed, unlocking the subscription-based features of Polkadot (and Substrate) clients. Some familiarity with RxJS is a requirement to use the API, however just understanding .subscribe and .pipe on Observables will unlock full-scale use thereof.
see: ApiPromise
Making rpc calls -
import ApiRx from '@polkadot/api/rx';
-
-// initialise via Promise & static create
-const api = await ApiRx.create().toPromise();
-
-// make a call to retrieve the current network head
-api.rpc.chain.subscribeNewHead().subscribe((header) => {
- console.log(`Chain is at #${header.blockNumber}`);
-});
- Subscribing to chain state -
import { combineLatest } from 'rxjs';
-import { pairwise, switchMap } from 'rxjs/operators';
-import { ApiRx, WsProvider } from '@polkadot/api';
-
-// initialise a provider with a specific endpoint
-const provider = new WsProvider('wss://example.com:9944')
-
-// initialise via isReady & new with specific provider
-new ApiRx(provider)
- .isReady
- .pipe(
- switchMap((api) =>
- combineLatest([
- api.query.timestamp.blockPeriod(),
- api.query.timestamp.now().pipe(pairwise())
- ])
- )
- )
- .subscribe(([blockPeriod, timestamp]) => {
- const elapsed = timestamp[1].toNumber() - timestamp[0].toNumber();
- console.log(`timestamp ${timestamp[1]} \nelapsed ${elapsed} \n(${blockPeriod}s target)`);
- });
- Submitting a transaction -
import { first, switchMap } from 'rxjs/operators';
-import ApiRx from '@polkadot/api/rx';
-
-// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
-import testingPairs from '@polkadot/keyring/testingPairs';
-const keyring = testingPairs();
-
-// get api via Promise
-const api = await ApiRx.create().toPromise();
-
-// retrieve nonce for the account
-api.query.system
- .accountNonce(keyring.alice.address())
- .pipe(
- first(),
- // pipe nonce into transfer
- switchMap((nonce) =>
- api.tx.balances
- // create transfer
- .transfer(keyring.bob.address(), 12345)
- // sign the transcation
- .sign(keyring.alice, { nonce })
- // send the transaction
- .send()
- )
- )
- // subscribe to overall result
- .subscribe(({ status, type }) => {
- if (type === 'Finalised') {
- console.log('Completed at block hash', status.asFinalised.toHex());
- }
- });
- ↳ ApiRx
⊕ new ApiRx(provider?: ApiOptions | ProviderInterface): ApiRx
Overrides ApiBase.constructor
Defined in rx/Api.ts:141
description: Create an instance of the ApiRx class
example:
import { switchMap } from 'rxjs/operators';
-import Api from '@polkadot/api/rx';
-
-new Api().isReady
- .pipe(
- switchMap((api) =>
- api.rpc.chain.subscribeNewHead()
- ))
- .subscribe((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
- });
- Parameters:
| Name | Type |
|---|---|
Optional provider | ApiOptions | ProviderInterface |
Returns: ApiRx
get derive(): Derive<RxResult, RxResult>
Defined in Base.ts:196
description: Derived results that are injected into the API, allowing for combinations of various query results.
example:
api.derive.chain.bestNumber((number) => {
- console.log('best number', number);
-});
- Returns: Derive<RxResult, RxResult>
get genesisHash(): Hash
Inherited from ApiBase.genesisHash
Defined in Base.ts:132
description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
Returns: Hash
get hasSubscriptions(): boolean
Inherited from ApiBase.hasSubscriptions
Defined in Base.ts:141
description: true when subscriptions are supported
Returns: boolean
get isConnected(): Observable<boolean>
Defined in rx/Api.ts:181
description: Observable that carries the connected state for the provider. Results in a boolean flag that is true/false based on the connectivity.
Returns: Observable<boolean>
get isReady(): Observable<ApiRx>
Defined in rx/Api.ts:188
description: Observable that returns the first time we are connected and loaded
Returns: Observable<ApiRx>
get libraryInfo(): string
Inherited from ApiBase.libraryInfo
Defined in Base.ts:148
description: The library information name & version (from package.json)
Returns: string
get query(): QueryableStorage<RxResult, RxResult>
Defined in Base.ts:216
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.
example:
api.query.balances.freeBalance(<accountId>, (balance) => {
- console.log('new balance', balance);
-});
- Returns: QueryableStorage<RxResult, RxResult>
get rpc(): DecoratedRpc<RxResult, RxResult>
Defined in Base.ts:236
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (usine known keys) and the submission of transactions.
example:
api.rpc.chain.subscribeNewHead((header) => {
- console.log('new header', header);
-});
- Returns: DecoratedRpc<RxResult, RxResult>
get runtimeMetadata(): Metadata
Inherited from ApiBase.runtimeMetadata
Defined in Base.ts:155
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: Metadata
get runtimeVersion(): RuntimeVersion
Inherited from ApiBase.runtimeVersion
Defined in Base.ts:164
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
get tx(): SubmittableExtrinsics<RxResult, RxResult>
Defined in Base.ts:254
description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
example:
api.tx.balances
- .transfer(<recipientId>, <balance>)
- .signAndSend(<keyPair>, ({status}) => {
- console.log('tx status', status.asFinalised.toHex());
- });
- Returns: SubmittableExtrinsics<RxResult, RxResult>
get type(): ApiType
Defined in Base.ts:173
description: The type of this API instance, either 'rxjs' or 'promise'
Returns: ApiType
▸ clone(): ApiRx
Defined in rx/Api.ts:195
description: Returns a clone of this ApiRx instance (new underlying provider connection)
Returns: ApiRx
▸ disconnect(): void
Implementation of ApiRxInterface.disconnect
Inherited from ApiBase.disconnect
Defined in Base.ts:263
description: Disconnect from the underlying provider, halting all comms
Returns: void
▸ on(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:286
description: Attach an eventemitter handler to listen to a specific event
example:
api.on('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.on('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ once(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:311
description: Attach an one-time eventemitter handler to listen to a specific event
example:
api.once('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.once('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ registerTypes(types?: RegistryTypes): void
Implementation of ApiRxInterface.registerTypes
Inherited from ApiBase.registerTypes
Defined in Base.ts:320
description: Register additional user-defined of chain-specific types in the type registry
Parameters:
| Name | Type |
|---|---|
Optional types | RegistryTypes |
Returns: void
▸ setSigner(signer: Signer): void
Implementation of ApiRxInterface.setSigner
Inherited from ApiBase.setSigner
Defined in Base.ts:180
description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
Parameters:
| Name | Type |
|---|---|
| signer | Signer |
Returns: void
<Static> create▸ create(options?: ApiOptions | ProviderInterface): Observable<ApiRx>
Defined in rx/Api.ts:139
description: Creates an ApiRx instance using the supplied provider. Returns an Observable containing the actual Api instance.
example:
import { switchMap } from 'rxjs/operators';
-import Api from '@polkadot/api/rx';
-
-Api.create()
- .pipe(
- switchMap((api) =>
- api.rpc.chain.subscribeNewHead()
- ))
- .subscribe((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
- });
- Parameters:
| Name | Type | Description |
|---|---|---|
Optional options | ApiOptions | ProviderInterface | options that is passed to the class contructor. Can be either ApiOptions or [[WsProvider]] |
Returns: Observable<ApiRx>
ConstructorDefobjectobjectobjectExtrinsic
↳ SubmittableExtrinsic
Codec⊕ new SubmittableExtrinsic(type: ApiType, api: ApiInterface$Rx, onCall: OnCallDefinition<CodecResult, SubscriptionResult>, extrinsic: Extrinsic | Method): SubmittableExtrinsic
Overrides Extrinsic.__constructor
Defined in SubmittableExtrinsic.ts:62
Parameters:
| Name | Type |
|---|---|
| type | ApiType |
| api | ApiInterface$Rx |
| onCall | OnCallDefinition<CodecResult, SubscriptionResult> |
| extrinsic | Extrinsic | Method |
Returns: SubmittableExtrinsic
● __@toStringTag: string
Inherited from Map.[Symbol.toStringTag]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:130
● size: number
Inherited from Map.size
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get Type(): E
Inherited from Struct.Type
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:160
description: Returns the Type description to sthe structure
Returns: E
get args(): Array<Codec>
Inherited from Extrinsic.args
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:76
description: The arguments passed to for the call, exposes args so it is compatible with [[Method]]
Returns: Array<Codec>
get callIndex(): Uint8Array
Inherited from Extrinsic.callIndex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:83
description: The actual [sectionIndex, methodIndex] as used in the Method
Returns: Uint8Array
get data(): Uint8Array
Inherited from Extrinsic.data
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:90
description: The actual data for the Method
Returns: Uint8Array
get encodedLength(): number
Inherited from Extrinsic.encodedLength
Overrides Struct.encodedLength
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:97
description: The length of the value when encoded as a Uint8Array
Returns: number
get hash(): Hash
Inherited from Extrinsic.hash
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:106
description: Convernience function, encodes the extrinsic and returns the actual hash
Returns: Hash
get isEmpty(): boolean
Inherited from Struct.isEmpty
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:145
description: Checks if the value is an empty value
Returns: boolean
get isSigned(): boolean
Inherited from Extrinsic.isSigned
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:115
description: true id the extrinsic is signed
Returns: boolean
get length(): number
Inherited from Extrinsic.length
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:122
description: The length of the encoded value
Returns: number
get meta(): FunctionMetadata
Inherited from Extrinsic.meta
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:129
description: The [[FunctionMetadata]] that describes the extrinsic
Returns: FunctionMetadata
get method(): Method
Inherited from Extrinsic.method
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:136
description: The [[Method]] this extrinsic wraps
Returns: Method
get signature(): ExtrinsicSignature
Inherited from Extrinsic.signature
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:143
description: The [[ExtrinsicSignature]]
Returns: ExtrinsicSignature
▸ __@iterator(): IterableIterator<[keyof S, Codec]>
Inherited from Map.[Symbol.iterator]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:113
Returns an iterable of entries in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ addSignature(signer: Address | Uint8Array, signature: Uint8Array, nonce: AnyNumber, era?: Uint8Array): Extrinsic
Inherited from Extrinsic.addSignature
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:150
description: Add an [[ExtrinsicSignature]] to the extrinsic (already generated)
Parameters:
| Name | Type |
|---|---|
| signer | Address | Uint8Array |
| signature | Uint8Array |
| nonce | AnyNumber |
Optional era | Uint8Array |
Returns: Extrinsic
▸ clear(): void
Inherited from Map.clear
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:22
Returns: void
▸ delete(key: keyof S): boolean
Inherited from Map.delete
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:23
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ entries(): IterableIterator<[keyof S, Codec]>
Inherited from Map.entries
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:118
Returns an iterable of key, value pairs for every entry in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ eq(other?: any): boolean
Inherited from Struct.eq
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:176
description: Compares the value of the input to see if there is a match
Parameters:
| Name | Type |
|---|---|
Optional other | any |
Returns: boolean
▸ forEach(callbackfn: function, thisArg?: any): void
Inherited from Map.forEach
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
Parameters:
| Name | Type |
|---|---|
| callbackfn | function |
Optional thisArg | any |
Returns: void
▸ get(name: keyof S): Codec | undefined
Inherited from Struct.get
Overrides Map.get
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:184
description: Returns a specific names entry in the structure
Parameters:
| Name | Type | Description |
|---|---|---|
| name | keyof S | The name of the entry to retrieve |
Returns: Codec | undefined
▸ getAtIndex(index: number): Codec
Inherited from Struct.getAtIndex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:191
description: Returns the values of a member at a specific index (Rather use get(name) for performance)
Parameters:
| Name | Type |
|---|---|
| index | number |
Returns: Codec
▸ has(key: keyof S): boolean
Inherited from Map.has
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:26
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ keys(): IterableIterator<keyof S>
Inherited from Map.keys
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:123
Returns an iterable of keys in the map
Returns: IterableIterator<keyof S>
▸ send(): SumbitableResultResult<CodecResult, SubscriptionResult>
▸ send(statusCb: function): SumbitableResultSubscription<CodecResult, SubscriptionResult>
Defined in SubmittableExtrinsic.ts:135
Returns: SumbitableResultResult<CodecResult, SubscriptionResult>
Defined in SubmittableExtrinsic.ts:136
Parameters:
| Name | Type |
|---|---|
| statusCb | function |
Returns: SumbitableResultSubscription<CodecResult, SubscriptionResult>
▸ set(key: keyof S, value: Codec): this
Inherited from Map.set
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:27
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
| value | Codec |
Returns: this
▸ sign(account: KeyringPair, _options: Partial<SignatureOptions>): SubmittableExtrinsic<CodecResult, SubscriptionResult>
Overrides Extrinsic.sign
Defined in SubmittableExtrinsic.ts:153
Parameters:
| Name | Type |
|---|---|
| account | KeyringPair |
| _options | Partial<SignatureOptions> |
Returns: SubmittableExtrinsic<CodecResult, SubscriptionResult>
▸ signAndSend(account: KeyringPair | string | AccountId | Address, options?: Partial<Partial<SignatureOptions>>): SumbitableResultResult<CodecResult, SubscriptionResult>
▸ signAndSend(account: KeyringPair | string | AccountId | Address, statusCb: StatusCb): SumbitableResultSubscription<CodecResult, SubscriptionResult>
Defined in SubmittableExtrinsic.ts:165
Parameters:
| Name | Type |
|---|---|
| account | KeyringPair | string | AccountId | Address |
Optional options | Partial<Partial<SignatureOptions>> |
Returns: SumbitableResultResult<CodecResult, SubscriptionResult>
Defined in SubmittableExtrinsic.ts:166
Parameters:
| Name | Type |
|---|---|
| account | KeyringPair | string | AccountId | Address |
| statusCb | StatusCb |
Returns: SumbitableResultSubscription<CodecResult, SubscriptionResult>
▸ toArray(): Array<Codec>
Inherited from Struct.toArray
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:198
description: Converts the Object to an standard JavaScript Array
Returns: Array<Codec>
▸ toHex(): string
Inherited from Extrinsic.toHex
Overrides Struct.toHex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:168
description: Returns a hex string representation of the value
Returns: string
▸ toJSON(): any
Inherited from Extrinsic.toJSON
Overrides Struct.toJSON
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:175
description: Converts the Object to JSON, typically used for RPC transfers
Returns: any
▸ toString(): string
Inherited from Struct.toString
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:226
description: Returns the string representation of the value
Returns: string
▸ toU8a(isBare?: undefined | false | true): Uint8Array
Inherited from Extrinsic.toU8a
Overrides Struct.toU8a
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:183
description: Encodes the value as a Uint8Array as per the parity-codec specifications
Parameters:
| Name | Type | Description |
|---|---|---|
Optional isBare | undefined | false | true | true when the value has none of the type-specific prefixes (internal) |
Returns: Uint8Array
▸ values(): IterableIterator<Codec>
Inherited from Map.values
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:128
Returns an iterable of values in the map
Returns: IterableIterator<Codec>
<Static> decodeExtrinsic▸ decodeExtrinsic(value: ExtrinsicValue | AnyU8a | Method): ExtrinsicValue | Array<number> | Uint8Array
Inherited from Extrinsic.decodeExtrinsic
Defined in /home/travis/build/polkadot-js/api/packages/types/src/type/Extrinsic.ts:44
Parameters:
| Name | Type |
|---|---|
| value | ExtrinsicValue | AnyU8a | Method |
Returns: ExtrinsicValue | Array<number> | Uint8Array
<Static> with▸ with<S>(Types: S): Constructor<Struct<S>>
Inherited from Struct.with
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:125
Type parameters:
ConstructorDefParameters:
| Name | Type |
|---|---|
| Types | S |
Returns: Constructor<Struct<S>>
ConstructorDefobjectobjectobjectStruct
↳ SubmittableResult
Codec⊕ new SubmittableResult(value?: any): SubmittableResult
Overrides Struct.__constructor
Defined in SubmittableExtrinsic.ts:28
Parameters:
| Name | Type |
|---|---|
Optional value | any |
Returns: SubmittableResult
● __@toStringTag: string
Inherited from Map.[Symbol.toStringTag]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:130
● size: number
Inherited from Map.size
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:28
get Type(): E
Inherited from Struct.Type
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:160
description: Returns the Type description to sthe structure
Returns: E
get encodedLength(): number
Inherited from Struct.encodedLength
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:167
description: The length of the value when encoded as a Uint8Array
Returns: number
get events(): Array<EventRecord>
Defined in SubmittableExtrinsic.ts:40
description: the contained events
Returns: Array<EventRecord>
get isEmpty(): boolean
Inherited from Struct.isEmpty
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:145
description: Checks if the value is an empty value
Returns: boolean
get status(): ExtrinsicStatus
Defined in SubmittableExtrinsic.ts:47
description: the status
Returns: ExtrinsicStatus
get type(): string
Defined in SubmittableExtrinsic.ts:54
description: the type
Returns: string
▸ __@iterator(): IterableIterator<[keyof S, Codec]>
Inherited from Map.[Symbol.iterator]
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:113
Returns an iterable of entries in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ clear(): void
Inherited from Map.clear
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:22
Returns: void
▸ delete(key: keyof S): boolean
Inherited from Map.delete
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:23
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ entries(): IterableIterator<[keyof S, Codec]>
Inherited from Map.entries
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:118
Returns an iterable of key, value pairs for every entry in the map.
Returns: IterableIterator<[keyof S, Codec]>
▸ eq(other?: any): boolean
Inherited from Struct.eq
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:176
description: Compares the value of the input to see if there is a match
Parameters:
| Name | Type |
|---|---|
Optional other | any |
Returns: boolean
▸ forEach(callbackfn: function, thisArg?: any): void
Inherited from Map.forEach
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:24
Parameters:
| Name | Type |
|---|---|
| callbackfn | function |
Optional thisArg | any |
Returns: void
▸ get(name: keyof S): Codec | undefined
Inherited from Struct.get
Overrides Map.get
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:184
description: Returns a specific names entry in the structure
Parameters:
| Name | Type | Description |
|---|---|---|
| name | keyof S | The name of the entry to retrieve |
Returns: Codec | undefined
▸ getAtIndex(index: number): Codec
Inherited from Struct.getAtIndex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:191
description: Returns the values of a member at a specific index (Rather use get(name) for performance)
Parameters:
| Name | Type |
|---|---|
| index | number |
Returns: Codec
▸ has(key: keyof S): boolean
Inherited from Map.has
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:26
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
Returns: boolean
▸ keys(): IterableIterator<keyof S>
Inherited from Map.keys
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:123
Returns an iterable of keys in the map
Returns: IterableIterator<keyof S>
▸ set(key: keyof S, value: Codec): this
Inherited from Map.set
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.collection.d.ts:27
Parameters:
| Name | Type |
|---|---|
| key | keyof S |
| value | Codec |
Returns: this
▸ toArray(): Array<Codec>
Inherited from Struct.toArray
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:198
description: Converts the Object to an standard JavaScript Array
Returns: Array<Codec>
▸ toHex(): string
Inherited from Struct.toHex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:205
description: Returns a hex string representation of the value
Returns: string
▸ toJSON(): any
Inherited from Struct.toJSON
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:212
description: Converts the Object to JSON, typically used for RPC transfers
Returns: any
▸ toString(): string
Inherited from Struct.toString
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:226
description: Returns the string representation of the value
Returns: string
▸ toU8a(isBare?: undefined | false | true): Uint8Array
Inherited from Struct.toU8a
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:234
description: Encodes the value as a Uint8Array as per the parity-codec specifications
Parameters:
| Name | Type | Description |
|---|---|---|
Optional isBare | undefined | false | true | true when the value has none of the type-specific prefixes (internal) |
Returns: Uint8Array
▸ values(): IterableIterator<Codec>
Inherited from Map.values
Defined in /home/travis/build/polkadot-js/api/node_modules/typescript/lib/lib.es2015.iterable.d.ts:128
Returns an iterable of values in the map
Returns: IterableIterator<Codec>
<Static> with▸ with<S>(Types: S): Constructor<Struct<S>>
Inherited from Struct.with
Defined in /home/travis/build/polkadot-js/api/packages/types/src/codec/Struct.ts:125
Type parameters:
ConstructorDefParameters:
| Name | Type |
|---|---|
| Types | S |
Returns: Constructor<Struct<S>>
The Polkadot-JS API provides easy-to-use wrappers around JSONRPC calls that flow from an application to a node. It handles all the encoding and decoding or parameters, provides access to RPC functions and allows for the query of chain state and the submission of transactions.
The API wrappers provide a standard interface for use -
.create(<optional ApiOptions>) that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions { provider: <Optional WsProvider>, types: <Optional RegistryTypes> }.new Api(<optional ApiOptions>), exposing the isReady getterapi.rpc.<section>.<method> provides access to actual RPC calls, be it for queries, submission or retrieving chain information
-api.query.<section>.<method> provides access to chain state queries. These are dynamically populated based on what the runtime provides
-api.tx.<section>.<method> provides the ability to create a transaction, like chain state, this list is populated from a runtime query
-There are two flavours of the API provided, one allowing a standard interface via JavaScript Promises and the second provides an Observable wrapper using RxJS. Depending on your use-case and familiarity, you can choose either (or even both) for your application.
.create(...). Additionally any subscription method uses (value) => {} callbacks, returning the value as the subscription is updated..create(...). In the same fashion subscription-based methods return long-running Observables that update with the latest values.Substrate (upon which Polkadot is built) uses on-chain WASM runtimes, allowing for upgradability. Each runtime defining the actual chain extrinsics (submitted transactions and block intrinsics) as well as available entries in the chain state. Due to this, the API endpoints for queries and transactions are dynamically populated from the running chain.
Due to this dynamic nature, this API departs from traditional APIs which only has fixed endpoints, driving use by what is available by the runtime. As a start, this generic nature has a learning curve, although the provided documentation, examples and linked documentation tries to make that experience as seamless as possible.
Installation -
npm install --save @polkadot/api
- Subscribing to blocks via Promise-based API -
import { ApiPromise } from '@polkadot/api';
-
-// initialise via static create
-const api = await ApiPromise.create();
-
-// make a call to retrieve the current network head
-api.rpc.chain.subscribeNewHead((header) => {
- console.log(`Chain is at #${header.blockNumber}`);
-});
- Subscribing to blocks via RxJS-based API -
import { ApiRx } from '@polkadot/api';
-
-// initialise via static create
-const api = await ApiRx.create().toPromise();
-
-// make a call to retrieve the current network head
-api.rpc.chain.subscribeNewHead().subscribe((header) => {
- console.log(`Chain is at #${header.blockNumber}`);
-});
- Additional types used by runtime modules can be added when a new instance of the API is created. This is necessary if the runtime modules use types which are not available in the base Substrate runtime.
import { ApiPromise } from '@polkadot/api';
-
-// initialise via static create and register custom types
-const api = await ApiPromise.create({
- types: {
- CustomTypesExample: {
- "id": "u32",
- "data": "Vec<u8>",
- "deposit": "Balance",
- "owner": "AccountId",
- "application_expiry": "Moment",
- "whitelisted": "bool",
- "challenge_id": "u32"
- }
- }
-});
- Some of the users of the API (let us know if you are missing from the list), include -
- ← - - System events (defaults) - - @polkadot/types - - → -
ApiBase<CodecResult, SubscriptionResult>
↳ ApiPromiseInterface
⊕ new ApiPromiseInterface(provider?: ApiOptions | ProviderInterface, type: ApiType): ApiPromiseInterface
Inherited from ApiBase.constructor
Defined in Base.ts:81
description: Create an instance of the class
example:
import Api from '@polkadot/api/promise';
-
-const api = new Api().isReady();
-
-api.rpc.subscribeNewHead((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
-});
- Parameters:
| Name | Type | Default value |
|---|---|---|
Default value provider | ApiOptions | ProviderInterface | {} |
| type | ApiType | - |
Returns: ApiPromiseInterface
● isReady: Promise<ApiPromiseInterface>
Defined in promise/types.ts:16
get derive(): Derive<CodecResult, SubscriptionResult>
Defined in Base.ts:196
description: Derived results that are injected into the API, allowing for combinations of various query results.
example:
api.derive.chain.bestNumber((number) => {
- console.log('best number', number);
-});
- Returns: Derive<CodecResult, SubscriptionResult>
get genesisHash(): Hash
Inherited from ApiBase.genesisHash
Defined in Base.ts:132
description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
Returns: Hash
get hasSubscriptions(): boolean
Inherited from ApiBase.hasSubscriptions
Defined in Base.ts:141
description: true when subscriptions are supported
Returns: boolean
get libraryInfo(): string
Inherited from ApiBase.libraryInfo
Defined in Base.ts:148
description: The library information name & version (from package.json)
Returns: string
get query(): QueryableStorage<CodecResult, SubscriptionResult>
Defined in Base.ts:216
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.
example:
api.query.balances.freeBalance(<accountId>, (balance) => {
- console.log('new balance', balance);
-});
- Returns: QueryableStorage<CodecResult, SubscriptionResult>
get rpc(): DecoratedRpc<CodecResult, SubscriptionResult>
Defined in Base.ts:236
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (usine known keys) and the submission of transactions.
example:
api.rpc.chain.subscribeNewHead((header) => {
- console.log('new header', header);
-});
- Returns: DecoratedRpc<CodecResult, SubscriptionResult>
get runtimeMetadata(): Metadata
Inherited from ApiBase.runtimeMetadata
Defined in Base.ts:155
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: Metadata
get runtimeVersion(): RuntimeVersion
Inherited from ApiBase.runtimeVersion
Defined in Base.ts:164
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
get tx(): SubmittableExtrinsics<CodecResult, SubscriptionResult>
Defined in Base.ts:254
description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
example:
api.tx.balances
- .transfer(<recipientId>, <balance>)
- .signAndSend(<keyPair>, ({status}) => {
- console.log('tx status', status.asFinalised.toHex());
- });
- Returns: SubmittableExtrinsics<CodecResult, SubscriptionResult>
get type(): ApiType
Defined in Base.ts:173
description: The type of this API instance, either 'rxjs' or 'promise'
Returns: ApiType
▸ disconnect(): void
Inherited from ApiBase.disconnect
Defined in Base.ts:263
description: Disconnect from the underlying provider, halting all comms
Returns: void
▸ on(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:286
description: Attach an eventemitter handler to listen to a specific event
example:
api.on('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.on('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ once(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:311
description: Attach an one-time eventemitter handler to listen to a specific event
example:
api.once('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.once('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ registerTypes(types?: RegistryTypes): void
Inherited from ApiBase.registerTypes
Defined in Base.ts:320
description: Register additional user-defined of chain-specific types in the type registry
Parameters:
| Name | Type |
|---|---|
Optional types | RegistryTypes |
Returns: void
▸ setSigner(signer: Signer): void
Inherited from ApiBase.setSigner
Defined in Base.ts:180
description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
Parameters:
| Name | Type |
|---|---|
| signer | Signer |
Returns: void
↳ ApiRxInterface
⊕ new ApiRxInterface(provider?: ApiOptions | ProviderInterface, type: ApiType): ApiRxInterface
Inherited from ApiBase.constructor
Defined in Base.ts:81
description: Create an instance of the class
example:
import Api from '@polkadot/api/promise';
-
-const api = new Api().isReady();
-
-api.rpc.subscribeNewHead((header) => {
- console.log(`new block #${header.blockNumber.toNumber()}`);
-});
- Parameters:
| Name | Type | Default value |
|---|---|---|
Default value provider | ApiOptions | ProviderInterface | {} |
| type | ApiType | - |
Returns: ApiRxInterface
● isConnected: Observable<boolean>
Defined in rx/types.ts:13
● isReady: Observable<ApiRxInterface>
Defined in rx/types.ts:14
get derive(): Derive<RxResult, RxResult>
Defined in Base.ts:196
description: Derived results that are injected into the API, allowing for combinations of various query results.
example:
api.derive.chain.bestNumber((number) => {
- console.log('best number', number);
-});
- Returns: Derive<RxResult, RxResult>
get genesisHash(): Hash
Inherited from ApiBase.genesisHash
Defined in Base.ts:132
description: Contains the genesis Hash of the attached chain. Apart from being useful to determine the actual chain, it can also be used to sign immortal transactions.
Returns: Hash
get hasSubscriptions(): boolean
Inherited from ApiBase.hasSubscriptions
Defined in Base.ts:141
description: true when subscriptions are supported
Returns: boolean
get libraryInfo(): string
Inherited from ApiBase.libraryInfo
Defined in Base.ts:148
description: The library information name & version (from package.json)
Returns: string
get query(): QueryableStorage<RxResult, RxResult>
Defined in Base.ts:216
description: Contains all the chain state modules and their subsequent methods in the API. These are attached dynamically from the runtime metadata.
All calls inside the namespace, is denoted by section.method and may take an optional query parameter. As an example, api.query.timestamp.now() (current block timestamp) does not take parameters, while api.query.system.accountNonce(<accountId>) (retrieving the associated nonce for an account), takes the AccountId as a parameter.
example:
api.query.balances.freeBalance(<accountId>, (balance) => {
- console.log('new balance', balance);
-});
- Returns: QueryableStorage<RxResult, RxResult>
get rpc(): DecoratedRpc<RxResult, RxResult>
Defined in Base.ts:236
description: Contains all the raw rpc sections and their subsequent methods in the API as defined by the jsonrpc interface definitions. Unlike the dynamic api.query and api.tx sections, these methods are fixed (although extensible with node upgrades) and not determined by the runtime.
RPC endpoints available here allow for the query of chain, node and system information, in addition to providing interfaces for the raw queries of state (usine known keys) and the submission of transactions.
example:
api.rpc.chain.subscribeNewHead((header) => {
- console.log('new header', header);
-});
- Returns: DecoratedRpc<RxResult, RxResult>
get runtimeMetadata(): Metadata
Inherited from ApiBase.runtimeMetadata
Defined in Base.ts:155
description: Yields the current attached runtime metadata. Generally this is only used to construct extrinsics & storage, but is useful for current runtime inspection.
Returns: Metadata
get runtimeVersion(): RuntimeVersion
Inherited from ApiBase.runtimeVersion
Defined in Base.ts:164
description: Contains the version information for the current runtime.
Returns: RuntimeVersion
get tx(): SubmittableExtrinsics<RxResult, RxResult>
Defined in Base.ts:254
description: Contains all the extrinsic modules and their subsequent methods in the API. It allows for the construction of transactions and the submission thereof. These are attached dynamically from the runtime metadata.
example:
api.tx.balances
- .transfer(<recipientId>, <balance>)
- .signAndSend(<keyPair>, ({status}) => {
- console.log('tx status', status.asFinalised.toHex());
- });
- Returns: SubmittableExtrinsics<RxResult, RxResult>
get type(): ApiType
Defined in Base.ts:173
description: The type of this API instance, either 'rxjs' or 'promise'
Returns: ApiType
▸ disconnect(): void
Inherited from ApiBase.disconnect
Defined in Base.ts:263
description: Disconnect from the underlying provider, halting all comms
Returns: void
▸ on(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:286
description: Attach an eventemitter handler to listen to a specific event
example:
api.on('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.on('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ once(type: ApiInterface$Events, handler: function): this
Defined in Base.ts:311
description: Attach an one-time eventemitter handler to listen to a specific event
example:
api.once('connected', () => {
- console.log('API has been connected to the endpoint');
-});
-
-api.once('disconnected', () => {
- console.log('API has been disconnected from the endpoint');
-});
- Parameters:
| Name | Type | Description |
|---|---|---|
| type | ApiInterface$Events | The type of event to listen to. Available events are `connected`, `disconnected`, `ready` and `error` |
| handler | function | The callback to be called when the event fires. Depending on the event type, it could fire with additional arguments. |
Returns: this
▸ registerTypes(types?: RegistryTypes): void
Inherited from ApiBase.registerTypes
Defined in Base.ts:320
description: Register additional user-defined of chain-specific types in the type registry
Parameters:
| Name | Type |
|---|---|
Optional types | RegistryTypes |
Returns: void
▸ setSigner(signer: Signer): void
Inherited from ApiBase.setSigner
Defined in Base.ts:180
description: Set an external signer which will be used to sign extrinsic when account passed in is not KeyringPair
Parameters:
| Name | Type |
|---|---|
| signer | Signer |
Returns: void
object
↳ ApiBaseInterface
● on: function
Defined in types.ts:158
▸(type: ApiInterface$Events, handler: function): this
Parameters:
| Name | Type |
|---|---|
| type | ApiInterface$Events |
| handler | function |
Returns: this
● once: function
Defined in types.ts:159
▸(type: ApiInterface$Events, handler: function): this
Parameters:
| Name | Type |
|---|---|
| type | ApiInterface$Events |
| handler | function |
Returns: this
● type: ApiType
Defined in types.ts:156
ApiInterface$Decorated
● derive: Derive<CodecResult, SubscriptionResult>
Defined in types.ts:142
● genesisHash: Hash
Defined in types.ts:138
● hasSubscriptions: boolean
Defined in types.ts:139
● query: QueryableStorage<CodecResult, SubscriptionResult>
Defined in types.ts:143
● rpc: DecoratedRpc<CodecResult, SubscriptionResult>
Defined in types.ts:144
● runtimeMetadata: Metadata
Defined in types.ts:140
● runtimeVersion: RuntimeVersion
Defined in types.ts:141
<Optional> signer● signer: Signer
Defined in types.ts:146
● tx: SubmittableExtrinsics<CodecResult, SubscriptionResult>
Defined in types.ts:145
ApiOptions
<Optional> derives● derives: DeriveCustom
Defined in types.ts:116
description: Add custom derives to be injected
<Optional> provider● provider: ProviderInterface
Defined in types.ts:121
description: Transport Provider from rpc-provider. If not specified, it will default to connecting to a WsProvider connecting localhost with the default port, i.e. ws://127.0.0.1:9944
<Optional> signer● signer: Signer
Defined in types.ts:125
description: An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
<Optional> source● source: ApiBase<any, any>
Defined in types.ts:129
description: The source object to use for runtime information (only used when cloning)
<Optional> types● types: RegistryTypes
Defined in types.ts:134
description: Additional types used by runtime modules. This is nessusary if the runtime modules uses types not available in the base Substrate runtime.
DecoratedRpc
● author: DecoratedRpc$Section<CodecResult, SubscriptionResult>
Defined in types.ts:34
● chain: DecoratedRpc$Section<CodecResult, SubscriptionResult>
Defined in types.ts:35
● state: DecoratedRpc$Section<CodecResult, SubscriptionResult>
Defined in types.ts:36
● system: DecoratedRpc$Section<CodecResult, SubscriptionResult>
Defined in types.ts:37
DecoratedRpc$Method
▸ __call(callback: CodecCallback): SubscriptionResult
▸ __call(arg1: CodecArg, callback: CodecCallback): SubscriptionResult
▸ __call(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): CodecResult
Defined in types.ts:23
Parameters:
| Name | Type |
|---|---|
| callback | CodecCallback |
Returns: SubscriptionResult
Defined in types.ts:24
Parameters:
| Name | Type |
|---|---|
| arg1 | CodecArg |
| callback | CodecCallback |
Returns: SubscriptionResult
Defined in types.ts:25
Parameters:
| Name | Type |
|---|---|
Optional arg1 | CodecArg |
Optional arg2 | CodecArg |
Optional arg3 | CodecArg |
Returns: CodecResult
DecoratedRpc$Section
[index: string]: DecoratedRpc$Method<CodecResult, SubscriptionResult>
Derive
[index: string]: DeriveSection<CodecResult, SubscriptionResult>
DeriveMethodBase
▸ __call(...params: Array<CodecArg>): CodecResult
Defined in types.ts:88
Parameters:
| Name | Type |
|---|---|
Rest params | Array<CodecArg> |
Returns: CodecResult
DeriveSection
[index: string]: DeriveMethod<CodecResult, SubscriptionResult>
QueryableModuleStorage
[index: string]: QueryableStorageFunction<CodecResult, SubscriptionResult>
QueryableStorage
[index: string]: QueryableModuleStorage<CodecResult, SubscriptionResult>
StorageFunction
↳ QueryableStorageFunctionBase
▸ __call(arg?: CodecArg): CodecResult
▸ __call(arg?: any): Uint8Array
Defined in types.ts:50
Parameters:
| Name | Type |
|---|---|
Optional arg | CodecArg |
Returns: CodecResult
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/StorageKey.ts:12
Parameters:
| Name | Type |
|---|---|
Optional arg | any |
Returns: Uint8Array
● at: function
Defined in types.ts:52
▸(hash: Hash | Uint8Array | string, arg?: CodecArg): CodecResult
Parameters:
| Name | Type |
|---|---|
| hash | Hash | Uint8Array | string |
Optional arg | CodecArg |
Returns: CodecResult
● hash: function
Defined in types.ts:53
▸(arg?: CodecArg): HashResult<CodecResult, SubscriptionResult>
Parameters:
| Name | Type |
|---|---|
Optional arg | CodecArg |
Returns: HashResult<CodecResult, SubscriptionResult>
● key: function
Defined in types.ts:54
▸(arg?: CodecArg): string
Parameters:
| Name | Type |
|---|---|
Optional arg | CodecArg |
Returns: string
● meta: StorageFunctionMetadata
Inherited from StorageFunction.meta
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/StorageKey.ts:14
● method: string
Inherited from StorageFunction.method
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/StorageKey.ts:15
● section: string
Inherited from StorageFunction.section
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/StorageKey.ts:16
● size: function
Defined in types.ts:55
▸(arg?: CodecArg): U64Result<CodecResult, SubscriptionResult>
Parameters:
| Name | Type |
|---|---|
Optional arg | CodecArg |
Returns: U64Result<CodecResult, SubscriptionResult>
● toJSON: function
Inherited from StorageFunction.toJSON
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/StorageKey.ts:17
▸(): any
Returns: any
Signer
<Optional> update● update: undefined | function
Defined in types.ts:171
description: Receives an update for the extrinsic signed by a signer.sign
▸ sign(extrinsic: Extrinsic, address: string, options: SignatureOptions): Promise<number>
Defined in types.ts:166
description: Signs an extrinsic, returning an id (>0) that can be used to retrieve updates
Parameters:
| Name | Type |
|---|---|
| extrinsic | Extrinsic |
| address | string |
| options | SignatureOptions |
Returns: Promise<number>
MethodFunction
↳ SubmittableExtrinsicFunction
▸ __call(...params: Array<CodecArg>): SubmittableExtrinsic<CodecResult, SubscriptionResult>
▸ __call(...args: any[]): Method
Defined in types.ts:76
Parameters:
| Name | Type |
|---|---|
Rest params | Array<CodecArg> |
Returns: SubmittableExtrinsic<CodecResult, SubscriptionResult>
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:28
Parameters:
| Name | Type |
|---|---|
Rest args | any[] |
Returns: Method
● callIndex: Uint8Array
Inherited from MethodFunction.callIndex
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:30
● meta: FunctionMetadata
Inherited from MethodFunction.meta
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:31
● method: string
Inherited from MethodFunction.method
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:32
● section: string
Inherited from MethodFunction.section
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:33
● toJSON: function
Inherited from MethodFunction.toJSON
Defined in /home/travis/build/polkadot-js/api/packages/types/src/primitive/Method.ts:34
▸(): any
Returns: any
SubmittableExtrinsics
[index: string]: SubmittableModuleExtrinsics<CodecResult, SubscriptionResult>
SubmittableModuleExtrinsics
[index: string]: SubmittableExtrinsicFunction<CodecResult, SubscriptionResult>
Ƭ CombinatorCallback: function
Defined in promise/Combinator.ts:9
▸(value: Array<any>): any
Parameters:
| Name | Type |
|---|---|
| value | Array<any> |
Returns: any
Ƭ CombinatorFunction: function
Defined in promise/Combinator.ts:10
▸(cb: function): SubscriptionResult
Parameters:
| Name | Type |
|---|---|
| cb | function |
Returns: SubscriptionResult
Ƭ CodecResult: Promise<Codec>
Defined in promise/types.ts:13
Ƭ QueryableStorageFunction: QueryableStorageFunctionBase<CodecResult, SubscriptionResult>
Defined in promise/types.ts:19
Ƭ SubmittableExtrinsic: SubmittableExtrinsicBase<CodecResult, SubscriptionResult>
Defined in promise/types.ts:20
Ƭ SubmittableExtrinsicFunction: SubmittableExtrinsicFunctionBase<CodecResult, SubscriptionResult>
Defined in promise/types.ts:21
Ƭ SubscriptionResult: Promise<function>
Defined in promise/types.ts:11
Ƭ RxResult: Observable<Codec>
Defined in rx/types.ts:10
Ƭ ApiInterface$Events: RpcRxInterface$Events | "ready"
Defined in types.ts:151
Ƭ ApiInterface$Rx: ApiInterface$Decorated<RxResult, RxResult>
Defined in types.ts:149
Ƭ ApiType: "promise" | "rxjs"
Defined in types.ts:153
Ƭ DeriveMethod: DeriveMethod<CodecResult, SubscriptionResult>
Defined in types.ts:99
Ƭ HashResult: HashResult<CodecResult, SubscriptionResult>
Defined in types.ts:40
Ƭ OnCallDefinition: function
Defined in types.ts:18
▸(method: OnCallFunction<RxResult, RxResult>, params?: Array<CodecArg>, callback?: CodecCallback, needsCallback?: undefined | false | true): CodecResult | SubscriptionResult
Parameters:
| Name | Type |
|---|---|
| method | OnCallFunction<RxResult, RxResult> |
Optional params | Array<CodecArg> |
Optional callback | CodecCallback |
Optional needsCallback | undefined | false | true |
Returns: CodecResult | SubscriptionResult
Ƭ OnCallFunction: function
Defined in types.ts:20
▸(...params: Array<CodecArg>): CodecResult | SubscriptionResult
Parameters:
| Name | Type |
|---|---|
Rest params | Array<CodecArg> |
Returns: CodecResult | SubscriptionResult
Ƭ QueryableStorageFunction: QueryableStorageFunction<CodecResult, SubscriptionResult>
Defined in types.ts:63
Ƭ U64Result: U64Result<CodecResult, SubscriptionResult>
Defined in types.ts:45
▸ filterEvents(extHash: Hash, __namedParameters: object, allEvents: Array<EventRecord>): Array<EventRecord> | undefined
Defined in util/filterEvents.ts:9
Parameters:
| Name | Type |
|---|---|
| extHash | Hash |
| __namedParameters | object |
| allEvents | Array<EventRecord> |
Returns: Array<EventRecord> | undefined