Auto Consensus
Available Functions
Account Management
account(api: Api, address: string): Promise<AccountData>
: Retrieves account information including nonce and balance data.balance(api: Api, address: string): Promise<BalanceData>
: Retrieves the balance data of a given address.
Balances
totalIssuance(networkId?: string): Promise<BigInt>
: Retrieves the total token issuance in the network.
Blockchain Information
block(api: Api): Promise<RawBlock>
: Retrieves the latest block data.blockHash(api: Api): Promise<string>
: Retrieves the hash of the latest block.blockNumber(api: Api): Promise<number>
: Retrieves the current block number.getInfo(): Promise<Info>
: Retrieves general blockchain information.networkTimestamp(api: Api): Promise<Codec>
: Retrieves the current network timestamp.
Consensus Information
blockchainSize(api: Api): Promise<bigint>
: Calculates the total size of the blockchain.maxPiecesInSector(api: Api): bigint
: Retrieves the maximum number of pieces allowed in a sector.segmentCommitment(api: Api): Promise<[StorageKey, Codec][]>
: Retrieves the segment commitments.shouldAdjustSolutionRange(api: Api): Promise<boolean>
: Determines whether the solution range should be adjusted.slotProbability(api: Api): [number, number]
: Retrieves the slot probability constants.solutionRangeToSectors(solutionRange: bigint, slotProbability: [bigint, bigint], piecesInSector: bigint): bigint
: Calculates the number of sectors based on the solution range, slot probability, and pieces in a sector.solutionRanges(api: Api): Promise<{ current: bigint | null; next: bigint | null; votingCurrent: bigint | null; votingNext: bigint | null }>
: Retrieves the current and next solution ranges.spacePledge(api: Api): Promise<bigint>
: Calculates the total space pledged by farmers.
Domains
domainStakingSummary(api: Api): Promise<DomainStakingSummary[]>
: Retrieves staking summaries for domains.domains(api: Api): Promise<DomainRegistry[]>
: Retrieves a list of domain registries.latestConfirmedDomainBlock(api: Api): Promise<ConfirmedDomainBlock[]>
: Retrieves the latest confirmed blocks for each domain.
Miscellaneous
blockchainSize(api: Api): Promise<bigint>
: Calculates the total size of the blockchain.spacePledge(api: Api): Promise<bigint>
: Calculates the total space pledged in the network.
Operators and Staking
deposits(api: Api, operatorId: StringNumberOrBigInt, account?: string): Promise<Deposit[]>
: Retrieves deposit information for an operator and optional account.deregisterOperator(params: StakingParams): SubmittableExtrinsic
: Creates a transaction to deregister an operator.nominateOperator(params: NominateOperatorParams): SubmittableExtrinsic
: Creates a transaction to nominate an operator and stake an amount.operator(api: Api, operatorId: StringNumberOrBigInt): Promise<OperatorDetails>
: Retrieves detailed information about a specific operator.operators(api: Api): Promise<Operator[]>
: Retrieves a list of all operators.registerOperator(params: RegisterOperatorParams): SubmittableExtrinsic
: Creates a transaction to register a new operator.unlockFunds(params: StakingParams): SubmittableExtrinsic
: Creates a transaction to unlock funds after operator deregistration.unlockNominator(params: StakingParams): SubmittableExtrinsic
: Creates a transaction to unlock a nominator's funds.withdrawStake(params: WithdrawStakeParams): SubmittableExtrinsic
: Creates a transaction to withdraw staked shares from an operator.withdrawals(api: Api, operatorId: StringNumberOrBigInt, account?: string): Promise<Withdrawal[]>
: Retrieves withdrawal information for an operator and optional account.
Transfers
transfer(api: ApiPromise, receiver: string, amount: Amount, allowDeath?: boolean): SubmittableExtrinsic
: Creates a transaction to transfer an amount to a receiver. UsestransferKeepAlive
ifallowDeath
is false, otherwise usestransferAllowDeath
.transferAll(api: ApiPromise, receiver: string, keepAlive?: boolean): SubmittableExtrinsic
: Creates a transaction to transfer all tokens to a receiver. IfkeepAlive
is true, keeps the sender's account alive.
Utility Functions
query<T>(api: Api, methodPath: string, params?: any[]): Promise<T>
: Queries the blockchain state for a specified method with optional parameters.remark(api: ApiPromise, remark: string, withEvent?: boolean): SubmittableExtrinsic
: Creates a remark transaction with or without an event.rpc<T>(api: Api, methodPath: string, params?: any[]): Promise<T>
: Performs an RPC call to a specified method with optional parameters.
Import Example
import { generateAddress, getBalance, stake, transfer, getInfo } from '@autonomys/auto-consensus'