• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    C#
  • License
    Apache License 2.0
  • Created almost 4 years ago
  • Updated 10 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A C# implementation of the WalletConnect client

WalletConnectSharp

WalletConnectSharp is an implementation of the WalletConnect protocol v2 using .NET. This library implements the WalletConnect Technical Specification in .NET to allow C# dApps makers and wallet makers to add support for the open WalletConnect protocol.

Installation

install via Nuget

dotnet add package WalletConnect.Sign

Usage

Dapp Usage

First you must setup SignClientOptions which stores both the ProjectId and Metadata. You may also optionally specify the storage module to use. By default, the FileSystemStorage module is used if none is specified.

var dappOptions = new SignClientOptions()
{
    ProjectId = "39f3dc0a2c604ec9885799f9fc5feb7c",
    Metadata = new Metadata()
    {
        Description = "An example dapp to showcase WalletConnectSharpv2",
        Icons = new[] { "https://walletconnect.com/meta/favicon.ico" },
        Name = "WalletConnectSharpv2 Dapp Example",
        Url = "https://walletconnect.com"
    },
    // Uncomment to disable persistant storage
    // Storage = new InMemoryStorage()
};

Then, you must setup the ConnectOptions which define what blockchain, RPC methods and events your dapp will use.

C# Constructor

var dappConnectOptions = new ConnectOptions()
{
    RequiredNamespaces = new RequiredNamespaces()
    {
        {
            "eip155", new RequiredNamespace()
            {
                Methods = new[]
                {
                    "eth_sendTransaction",
                    "eth_signTransaction",
                    "eth_sign",
                    "personal_sign",
                    "eth_signTypedData",
                },
                Chains = new[]
                {
                    "eip155:1"
                },
                Events = new[]
                {
                    "chainChanged",
                    "accountsChanged",
                }
            }
        }
    }
};

Builder Functions Style

var dappConnectOptions1 = new ConnectOptions()
    .RequireNamespace("eip155", new RequiredNamespace()
        .WithMethod("eth_sendTransaction")
        .WithMethod("eth_signTransaction")
        .WithMethod("eth_sign")
        .WithMethod("personal_sign")
        .WithMethod("eth_signTypedData")
        .WithChain("eip155:1")
        .WithEvent("chainChanged")
        .WithEvent("accountsChanged")
    );

With both options defined, you can initialize and connect the SDK

var dappClient = await WalletConnectSignClient.Init(dappOptions);
var connectData = await dappClient.Connect(dappConnectOptions);

You can grab the Uri for the connection request from connectData

ExampleShowQRCode(connectData.Uri);

and await for connection approval using the Approval Task object

Task<SessionData> sessionConnectTask = connectData.Approval;
SessionData sessionData = await sessionConnectTask;

// or
// SessionData sessionData = await connectData.Approval;

This Task will return the SessionData when the session was approved, or throw an exception when the session rquest has either

  • Timed out
  • Been Rejected

Wallet Usage

First you must setup SignClientOptions which stores both the ProjectId and Metadata. You may also optionally specify the storage module to use. By default, the FileSystemStorage module is used if none is specified.

var walletOptions = new SignClientOptions()
{
    ProjectId = "39f3dc0a2c604ec9885799f9fc5feb7c",
    Metadata = new Metadata()
    {
        Description = "An example wallet to showcase WalletConnectSharpv2",
        Icons = new[] { "https://walletconnect.com/meta/favicon.ico" },
        Name = "WalletConnectSharpv2 Wallet Example",
        Url = "https://walletconnect.com"
    },
    // Uncomment to disable persistant storage
    // Storage = new InMemoryStorage()
};

Once you have options defined, you can initialize the SDK

var walletClient = await WalletConnectSignClient.Init(walletOptions);

Wallets can pair an incoming session using the session's Uri. Pairing a session lets the Wallet obtain the connection proposal which can then be approved or denied.

ProposalStruct proposal = await walletClient.Pair(connectData.Uri);

The wallet can then approve or reject the proposal using either of the following

string addressToConnect = ...;
var approveData = await walletClient.Approve(proposal, addressToConnect);
await approveData.Acknowledged();
string[] addressesToConnect = ...;
var approveData = await walletClient.Approve(proposal, addressesToConnect);
await approveData.Acknowledged();
await walletClient.Reject(proposal, "User rejected");

Examples

There are examples and unit tests in the Tests directory. Some examples include

  • BiDirectional Communication
  • Basic dApp Example

More Repositories

1

web3modal

A single Web3 provider solution for all Wallets
TypeScript
4,753
star
2

create-eth-app

Create Ethereum-powered apps with one command
JavaScript
2,746
star
3

walletconnect-monorepo

WalletConnect Monorepo
TypeScript
1,455
star
4

walletconnect-docs

WalletConnect Documentation
CSS
449
star
5

walletconnect-example-dapp

Example Dapp
TypeScript
367
star
6

web-examples

Wallet and dapp examples implementing WalletConnect v2
TypeScript
358
star
7

WalletConnectSwift

WalletConnect Swift SDK
Swift
328
star
8

WalletConnectSwiftV2

WalletConnect Swift SDK v2
Swift
251
star
9

walletconnect-test-wallet

Test Wallet (Web)
TypeScript
186
star
10

web3modal-vanilla-js-example

An example application how to use Web3modal from vanilla JavaScript
JavaScript
169
star
11

WalletConnectKotlinV2

WalletConnect Kotlin SDK v2
Kotlin
168
star
12

kotlin-walletconnect-lib

library to use WalletConnect with Kotlin or Java
Kotlin
156
star
13

a2

An Asynchronous Apple Push Notification (apns2) Client for Rust
Rust
142
star
14

walletconnect-website

WalletConnect Website
TypeScript
125
star
15

WalletConnectUnity

An extension of WalletConnectSharp that brings WalletConnect to Unity 🎮
C#
118
star
16

walletconnect-registry

App Registry for WalletConnect Protocol
JavaScript
115
star
17

walletconnect-utils

Javascript Utilities for WalletConnect
TypeScript
113
star
18

WalletConnectFlutterV2

WalletConnect v2 client made in Dart for Flutter.
Dart
103
star
19

react-native-examples

React Native examples implementing WalletConnect v2
TypeScript
75
star
20

py-walletconnect-bridge

WalletConnect Bridge Python Implementation
Python
64
star
21

web3modal-examples

JavaScript
57
star
22

awesome-walletconnect

A curated list of awesome WalletConnect resources, libraries, tools and more
55
star
23

walletconnect-assets

WalletConnect Brand Guidelines
55
star
24

walletconnect-demo-app

Demo React-Native App to Test WalletConnect integration
TypeScript
52
star
25

web3modal-react-native

Web3Modal React-Native SDK
TypeScript
51
star
26

web3modal-swift

Swift
50
star
27

node-walletconnect-bridge

[Deprecated] Moved to walletconnect-monorepo
Shell
48
star
28

web3inbox

TypeScript
46
star
29

EIP6963

A web application showcasing the implementation and usage of EIP-6963 for Multi Injected Provider Discovery
TypeScript
34
star
30

web3modal-checkout

Payment checkout with Web3Modal
TypeScript
33
star
31

Web3ModalFlutter

The Web3Modal for WalletConnect built using Flutter.
Dart
33
star
32

WalletConnectSwift-Example

Example code for WalletConnectSwift library
Swift
32
star
33

walletconnect-specs

WalletConnect Specifications
CSS
27
star
34

cosmos-wallet

Configurable Wallet for Cosmos SDK Chains
TypeScript
26
star
35

blockchain-api

WalletConnect's Blockchain API
Rust
26
star
36

modal-react-native

Simplest and most minimal way to connect your users with WalletConnect
TypeScript
25
star
37

WalletConnectRust

WalletConnect Rust SDK
Rust
23
star
38

create-wc-dapp

create-wc-dapp is an npx starter template that allows you to easily set up a WalletConnect integrated dApp.
TypeScript
23
star
39

firebase-walletconnect-push

WalletConnect Push Notification Firebase Webhook
TypeScript
22
star
40

relay

This repository contains the minimal relay server for WalletConnect v2.0
TypeScript
22
star
41

echo-server

WalletConnect Push Server Implementation
Rust
22
star
42

WalletConnectModalFlutter

The WalletConnectModal for WalletConnect built using Flutter.
Dart
20
star
43

gm-hackers

Get started in minutes with WalletConnect Notify API.
TypeScript
19
star
44

swift-walletconnect-lib

[Deprecated] Please refer to wallet-connect-swift repo
Swift
15
star
45

solib

Solana friendly API
TypeScript
14
star
46

WCIPs

WalletConnect Improvement Proposals
13
star
47

cloud-auth-api

PoC of the GoTrue replacement
HCL
10
star
48

cast-server

Rust
10
star
49

.github

10
star
50

auth-client-js

TypeScript
10
star
51

node-walletconnect-push

[Deprecated] Moved to walletconnect-monorepo
TypeScript
8
star
52

keys-server

Microservice to manage identity keys and invite keys for Chat SDK
Rust
7
star
53

association

WalletConnect Association (Verein) in Zug, Switzerland
6
star
54

CloudSIWE

Files that support Cloud's Ethereum login
HCL
6
star
55

session-keys-demo-contracts

Solidity
6
star
56

modal

WalletConnectModal repository
TypeScript
6
star
57

py-walletconnect-push

Reference Push Server implementation in Python3 for WalletConnect
Python
6
star
58

solana-wallet

TypeScript
5
star
59

Community

A place to store public documents related to our community
5
star
60

hyper-alpn

An ALPN connector for Hyper
Rust
5
star
61

KotlinCodingChallenge

Kotlin
5
star
62

chat-client-js

TypeScript
4
star
63

www-web3modal

Website for Web3Modal
TypeScript
4
star
64

notify-server

notify.walletconnect.com
Rust
4
star
65

actions

WalletConnect GitHub Actions
4
star
66

gm-dapp

dapp publishing example of WalletConnect Push
TypeScript
3
star
67

modal-swift

Swift
3
star
68

rs-common

Rust
3
star
69

gilgamesh

Rust
3
star
70

web3inbox-widget

TypeScript
2
star
71

notify-client-js

TypeScript
2
star
72

rust-http-starter

Starter project for a Rust HTTP server with Axum backed by a Postgres database
HCL
2
star
73

supabase-prometheus-exporter

Shell
2
star
74

terraform-null-label

HCL
2
star
75

verify-server

You either get in or you don't
Smarty
2
star
76

terraform-aws-dns

Terraform module to create a public Route53 zone for a fqdn and generate a wildcard certificate for it.
HCL
2
star
77

walletconnect-legacy

Monorepo for WalletConnect (v1.0) legacy JS packages
TypeScript
2
star
78

erc6492

Universal Etheruem signature verification with ERC-6492
Rust
2
star
79

gorgon

Analytics exporter
Rust
1
star
80

self-host-relay

1
star
81

cerberus

Rust
1
star
82

se-sdk

TypeScript
1
star
83

push-webhook-test-server

Test Server to allow us integ test our push offering
HCL
1
star
84

session-keys-demo

TypeScript
1
star