JsonRpcMethod<S, T> class
abstract
JSON RPC Method
An interface for JSON RPC methods.
Defines a JsonRpcMethod to invoke method with params (See JsonRpcContextMethod for response-context methods).
Use request to generate a new JSON RPC request and response to handle the result.
The decoder defines how the result property of a successful JSON RPC response is mapped from
S to T.
Example
class GetBlockHeight extends JsonRpcMethod<int, int> {
GetBlockHeight(): super('getBlockHeight');
@override int decoder(final int value) => value;
@override Object? params([Commitment? commitment]) => null;
}
final client = JsonRpcHttpClient(Cluster.devnet.uri);
final method = GetBlockHeight();
final response = await client.send(method.request(), method.response);
print(jsonEncode(response)); // {"jsonrpc":"2.0", "result":197469478, "id":1}
- Implementers
- AccountSubscribe
- GetAccountInfo
- GetBalance
- GetBlock
- GetBlockCommitment
- GetBlockHeight
- GetBlockProduction
- GetBlocks
- GetBlocksWithLimit
- GetBlockTime
- GetClusterNodes
- GetEpochInfo
- GetEpochSchedule
- GetFeeForMessage
- GetFirstAvailableBlock
- GetGenesisHash
- GetHealth
- GetHighestSnapshotSlot
- GetIdentity
- GetInflationGovernor
- GetInflationRate
- GetInflationReward
- GetLargestAccounts
- GetLatestBlockhash
- GetLeaderSchedule
- GetMaxRetransmitSlot
- GetMaxShredInsertSlot
- GetMinimumBalanceForRentExemption
- GetMultipleAccounts
- GetProgramAccounts
- GetRecentPerformanceSamples
- GetRecentPrioritizationFees
- GetSignaturesForAddress
- GetSignatureStatuses
- GetSlot
- GetSlotLeader
- GetSlotLeaders
- GetStakeActivation
- GetStakeMinimumDelegation
- GetSupply
- GetTokenAccountBalance
- GetTokenAccountsByDelegate
- GetTokenAccountsByOwner
- GetTokenLargestAccounts
- GetTokenSupply
- GetTransaction
- GetTransactionCount
- GetVersion
- GetVoteAccounts
- IsBlockhashValid
- LogsSubscribe
- MinimumLedgerSlot
- ProgramSubscribe
- RequestAirdrop
- SendTransaction
- SignatureSubscribe
- SimulateTransaction
- SlotSubscribe
Constructors
- JsonRpcMethod(String method)
-
Creates a handler to invoke
methodwith params.const
Properties
Methods
-
decoder(
S value) → T -
Decodes the
resultproperty of a successful JSON RPC response. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
params(
[Commitment? commitment]) → Object? -
Returns the JSON RPC request's
paramsproperty value. -
request(
[Commitment? commitment]) → JsonRpcRequest -
Creates a JsonRpcRequest to invoke method with params. The
commitmentlevel is provided as a default value to all methods that query bank state. -
response(
Map< String, dynamic> json) → JsonRpcResponse<T> -
Parses the
jsonRPC response and returns the result. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited