![]() |
VOOZH | about |
dotnet add package Nethereum.Wallet.RpcRequests --version 6.1.0
NuGet\Install-Package Nethereum.Wallet.RpcRequests -Version 6.1.0
<PackageReference Include="Nethereum.Wallet.RpcRequests" Version="6.1.0" />
<PackageVersion Include="Nethereum.Wallet.RpcRequests" Version="6.1.0" />Directory.Packages.props
<PackageReference Include="Nethereum.Wallet.RpcRequests" />Project file
paket add Nethereum.Wallet.RpcRequests --version 6.1.0
#r "nuget: Nethereum.Wallet.RpcRequests, 6.1.0"
#:package Nethereum.Wallet.RpcRequests@6.1.0
#addin nuget:?package=Nethereum.Wallet.RpcRequests&version=6.1.0Install as a Cake Addin
#tool nuget:?package=Nethereum.Wallet.RpcRequests&version=6.1.0Install as a Cake Tool
EIP-1193 JSON-RPC method handlers for wallet-dApp interaction. Provides handlers for account management, chain switching, signing requests, transaction approval, and permission management that bridge dApps to Nethereum wallet capabilities.
Nethereum.Wallet.RpcRequests implements EIP-1193 wallet RPC methods with user prompting and permission management. Each handler processes JSON-RPC requests from dApps and coordinates with wallet services to:
Supported RPC Methods:
eth_accounts, eth_requestAccountseth_chainId, wallet_addEthereumChain, wallet_switchEthereumChainpersonal_sign, eth_signTypedData_v4eth_sendTransactionwallet_requestPermissions, wallet_getPermissions, wallet_revokePermissionsdotnet add package Nethereum.Wallet.RpcRequests
Or via Package Manager Console:
Install-Package Nethereum.Wallet.RpcRequests
Package References:
All RPC method handlers extend RpcMethodHandlerBase which provides:
public abstract class RpcMethodHandlerBase : IRpcMethodHandler
{
public abstract string MethodName { get; }
public abstract Task<RpcResponseMessage> HandleAsync(
RpcRequestMessage request,
IWalletContext context);
// Error helpers
protected RpcResponseMessage MethodNotImplemented(object id);
protected RpcResponseMessage InvalidParams(object id, string? message = null);
protected RpcResponseMessage UserRejected(object id);
protected RpcResponseMessage InternalError(object id, string? message = null);
}
From: src/Nethereum.Wallet.RpcRequests/RpcMethodHandlerBase.cs:8
Returns the selected account address if dApp has permission.
// MethodName: "eth_accounts"
// Returns: [address] or [] if no permission
Behavior:
From: src/Nethereum.Wallet.RpcRequests/EthAccountsHandler.cs:10
Requests account access permission from user.
// MethodName: "eth_requestAccounts"
// Returns: [address] or error 4001 if rejected
Behavior:
From: src/Nethereum.Wallet.RpcRequests/EthRequestAccountsHandler.cs:10
Returns the current active chain ID.
// MethodName: "eth_chainId"
// Returns: "0x1" (hex-encoded chain ID)
Behavior:
From: src/Nethereum.Wallet.RpcRequests/EthChainIdHandler.cs:9
Adds a custom network or switches to existing network.
// MethodName: "wallet_addEthereumChain"
// Params: AddEthereumChainParameter
// Returns: null or error
Behavior:
From: src/Nethereum.Wallet.RpcRequests/WalletAddEthereumChainHandler.cs:13
AddEthereumChainParameter Structure:
chainId (required) - Hex-encoded chain IDchainName - Network namerpcUrls - Array of RPC URLsnativeCurrency - { name, symbol, decimals }blockExplorerUrls - Array of explorer URLsSwitches to a different network.
// MethodName: "wallet_switchEthereumChain"
// Params: SwitchEthereumChainParameter { chainId }
// Returns: null or error
Behavior:
From: src/Nethereum.Wallet.RpcRequests/WalletSwitchEthereumChainHandler.cs:10
Signs a personal message using eth_sign prefix.
// MethodName: "personal_sign"
// Params: [message, address] or [address, message]
// Returns: signature (hex) or error 4001 if rejected
Behavior:
From: src/Nethereum.Wallet.RpcRequests/PersonalSignHandler.cs:13
Message Detection:
From: src/Nethereum.Wallet.RpcRequests/PersonalSignHandler.cs:102
Signs EIP-712 typed structured data.
// MethodName: "eth_signTypedData_v4"
// Params: [address, typedDataJson]
// Returns: signature (hex) or error 4001 if rejected
Behavior:
From: src/Nethereum.Wallet.RpcRequests/EthSignTypedDataV4Handler.cs:14
Chain ID Validation:
var domainChainId = typedDataRaw.GetChainIdFromDomain();
var contextChainId = context.ChainId?.Value;
if (domainChainId != null && contextChainId != null && domainChainId != contextChainId)
{
return InvalidParams(id, $"Domain chainId {domainChainId} does not match active context chainId {contextChainId}");
}
From: src/Nethereum.Wallet.RpcRequests/EthSignTypedDataV4Handler.cs:51
Sends a transaction with user approval.
// MethodName: "eth_sendTransaction"
// Params: TransactionInput
// Returns: transaction hash (hex) or error 4001 if rejected
Behavior:
from field to selected account if not providedfrom address missingFrom: src/Nethereum.Wallet.RpcRequests/EthSendTransactionHandler.cs:15
Requests permissions for dApp.
// MethodName: "wallet_requestPermissions"
// Returns: [{ parentCapability: "eth_accounts", caveats: [] }] or error 4001
Behavior:
From: src/Nethereum.Wallet.RpcRequests/WalletRequestPermissionsHandler.cs:12
Response Format:
[
{
"parentCapability": "eth_accounts",
"caveats": []
}
]
Gets current permissions for dApp (implementation varies by wallet).
// MethodName: "wallet_getPermissions"
// Returns: permissions array
Revokes permissions for dApp (implementation varies by wallet).
// MethodName: "wallet_revokePermissions"
// Returns: null or error
Standard JSON-RPC error codes used by handlers:
public static class RpcErrors
{
// -32601: Method not found
public static RpcResponseMessage MethodNotFound(object id);
// -32602: Invalid parameters
public static RpcResponseMessage InvalidParams(object id, string? message = null);
// 4001: User rejected the request (EIP-1193)
public static RpcResponseMessage UserRejected(object id);
// -32603: Internal error
public static RpcResponseMessage InternalError(object id, string? message = null);
}
From: src/Nethereum.Wallet.RpcRequests/RpcErrors.cs:6
Error Code Reference:
Register all handlers with RpcHandlerRegistry:
using Nethereum.Wallet.RpcRequests;
using Nethereum.Wallet.Hosting;
var registry = new RpcHandlerRegistry();
// Register all wallet RPC handlers
WalletRpcHandlerRegistration.RegisterAll(registry);
From: src/Nethereum.Wallet.RpcRequests/WalletRpcHandlerRegistration.cs:8
Registered Handlers:
public static void RegisterAll(RpcHandlerRegistry registry)
{
registry.Register(new WalletAddEthereumChainHandler());
registry.Register(new WalletSwitchEthereumChainHandler());
registry.Register(new WalletGetPermissionsHandler());
registry.Register(new WalletRequestPermissionsHandler());
registry.Register(new WalletRevokePermissionsHandler());
registry.Register(new PersonalSignHandler());
registry.Register(new EthSignTypedDataV4Handler());
registry.Register(new EthRequestAccountsHandler());
registry.Register(new EthAccountsHandler());
registry.Register(new EthSendTransactionHandler());
registry.Register(new EthChainIdHandler());
// ... additional handlers
}
From: src/Nethereum.Wallet.RpcRequests/WalletRpcHandlerRegistration.cs:8
Handlers require IWalletContext which provides:
public interface IWalletContext
{
// Current state
IWalletAccount? SelectedWalletAccount { get; }
DappConnectionContext? SelectedDapp { get; }
HexBigInteger? ChainId { get; }
// Permission service
IDappPermissionService DappPermissions { get; }
// Configuration
IWalletConfigurationService Configuration { get; }
// User prompt methods
Task<string?> EnableProviderAsync();
Task<bool> RequestDappPermissionAsync(DappConnectionContext dapp, string account);
Task<string?> ShowTransactionDialogAsync(TransactionInput transaction);
Task<string?> RequestPersonalSignAsync(SignaturePromptContext context);
Task<string?> RequestTypedDataSignAsync(TypedDataSignPromptContext context);
Task<ChainAdditionPromptResult> RequestChainAdditionAsync(ChainAdditionPromptRequest request);
Task<ChainSwitchPromptResult> RequestChainSwitchAsync(ChainSwitchPromptRequest request);
}
using Nethereum.JsonRpc.Client.RpcMessages;
using Nethereum.Wallet.UI;
using Nethereum.Wallet.RpcRequests;
var handler = new EthRequestAccountsHandler();
// Simulated request from dApp
var request = new RpcRequestMessage
{
Id = 1,
Method = "eth_requestAccounts",
RawParameters = new object[] { }
};
// Handle request with wallet context
var response = await handler.HandleAsync(request, walletContext);
// Response contains:
// - Success: { id: 1, result: ["0x..."] }
// - Rejected: { id: 1, error: { code: 4001, message: "User rejected the request" } }
var handler = new PersonalSignHandler();
var request = new RpcRequestMessage
{
Id = 2,
Method = "personal_sign",
RawParameters = new object[]
{
"0x48656c6c6f", // "Hello" in hex
"0x742d35F3d3A4ab6b07a6d1e5c5f29fCB6b5e76e9"
}
};
var response = await handler.HandleAsync(request, walletContext);
// Handler:
// 1. Detects hex message
// 2. Decodes to "Hello"
// 3. Shows user both hex and decoded message
// 4. Prompts for signature
// 5. Returns signature or error 4001
var handler = new WalletAddEthereumChainHandler();
var addChainParam = new AddEthereumChainParameter
{
ChainId = "0x89", // Polygon
ChainName = "Polygon Mainnet",
RpcUrls = new[] { "https://polygon-rpc.com" },
NativeCurrency = new NativeCurrency
{
Name = "MATIC",
Symbol = "MATIC",
Decimals = 18
},
BlockExplorerUrls = new[] { "https://polygonscan.com" }
};
var request = new RpcRequestMessage
{
Id = 3,
Method = "wallet_addEthereumChain",
RawParameters = new object[] { addChainParam }
};
var response = await handler.HandleAsync(request, walletContext);
// Handler:
// 1. Checks if chain exists
// 2. If exists: prompts to switch
// 3. If new: prompts to add and switch
// 4. Returns null on success or error on rejection
using Nethereum.Wallet.Hosting;
using Nethereum.Wallet.RpcRequests;
var registry = new RpcHandlerRegistry();
WalletRpcHandlerRegistration.RegisterAll(registry);
var walletProvider = new NethereumWalletHostProvider(
vaultService,
rpcClientFactory,
storageService,
chainManagementService,
registry, // Handlers registered here
transactionPromptService,
signaturePromptService,
configurationService,
loginPromptService,
dappPermissionService,
dappPermissionPromptService,
chainAdditionPromptService,
chainSwitchPromptService);
// Wallet provider uses registry to handle incoming RPC requests
var web3 = await walletProvider.GetWeb3Async();
// web3.Client.OverridingRequestInterceptor intercepts and routes to handlers
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on Nethereum.Wallet.RpcRequests:
| Package | Downloads |
|---|---|
|
Nethereum.Wallet.UI.Components.Maui
MAUI helpers and Blazor WebView integration for hosting Nethereum wallet components on mobile and desktop. |
This package is not used by any popular GitHub repositories.