Skip to content

KBryan/EIP4337

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

EIP4337 C# Early Stages

This C# program is an example implementation of Ethereum Improvement Proposal 4337 (EIP-4337). The program demonstrates how to work with smart accounts in C#.

Todo: Add Smart Account Creation Script

Dependencies

The program uses several NuGet packages:

  • Nethereum.Signer for Ethereum message signing
  • Nethereum.Web3.Accounts for Ethereum account management
  • RestSharp for making HTTP requests
  • Newtonsoft.Json for JSON serialization and deserialization
  • Web3.Net for Ethereum smart contract interaction

Namespace and Classes

  • Namespace: EIP4337
  • Main Class: Program

Constants and Variables

  • signingKey: The private key used for signing messages and transactions.
  • rpcUrl: The URL of the Ethereum JSON-RPC endpoint.
  • chainId: The chain ID of the Ethereum network.
  • contractAddress: The Ethereum address of the smart contract.
  • mintingABI: The ABI (Application Binary Interface) of the smart contract.
  • _account: An Account object representing the Ethereum account.
  • _provider: A JsonRpcProvider object for interacting with the Ethereum network.
  • _contractMint: A Contract object for interacting with the smart contract.

Methods

Main(string[] args)

The main entry point of the program. It performs the following tasks:

  1. Initializes the _contractMint, _account, and _provider objects.
  2. Signs a message and prints it to the console.
  3. Generates the calldata for the safeMint function of the smart contract.
  4. Prints the balance of the account to the console.
  5. Creates various JSON-RPC request objects for different operations.
  6. Sends a JSON-RPC request to get the chain ID and prints the response.

Parameters

  • args: Command-line arguments (not used in this example).

SendRequestAsync(JsonRpcRequest jsonRpcRequest)

Sends a JSON-RPC request to the Ethereum network and returns the response.

Parameters

  • jsonRpcRequest: The JSON-RPC request object.

Returns

  • RestResponse: The response from the Ethereum network.

JSON-RPC Requests

  • eth_sendUserOperation: Sends a user operation to the Ethereum network.
  • eth_getUserOperationReceipt: Retrieves the receipt of a user operation.
  • eth_chainId: Gets the chain ID of the Ethereum network.
  • eth_getUserOperationByHash: Retrieves a user operation by its hash.
  • eth_supportedEntryPoints: Gets the supported entry points of the Ethereum network.
  • pm_sponsorUserOperation: Sponsors a user operation.
  • pm_accounts: Retrieves the accounts associated with a paymaster.

Usage

To run the program, compile it and execute the resulting binary. The program will output various information to the console, such as the signed message, calldata, and balance of the account.


This documentation provides an overview of the program's structure and functionality. For more details, refer to the inline comments in the code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages