# Player Connect Wallet

{% hint style="warning" %}
First make sure to setup your [Prerequisites](https://cryptonauts.gitbook.io/cryptonauts-docs/setup) and understand the [UI/UX Overview](https://cryptonauts.gitbook.io/cryptonauts-docs/auth/ux).
{% endhint %}

To enable players to Connect their Stacks Wallet ([Leather](https://chromewebstore.google.com/detail/leather/ldinpeekobnhjjdofggfgjlcehhmanlj) or [Xverse](https://chromewebstore.google.com/detail/xverse-bitcoin-crypto-wal/idnnbdplmphpflfnlkomgpfbpcgelopg)) to your UE5 based game. \
\
We will start with a Custom Event handler for the On Click of our Connect Wallet button.

### "Connect" Clicked

<figure><img src="https://873068673-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhHL6KhJKtaBfJbxztqID%2Fuploads%2FVqxs8IXJaCBjc9q4Cis6%2Fimage.png?alt=media&#x26;token=758e49fa-7b1b-43f3-9780-3942443b85e0" alt=""><figcaption></figcaption></figure>

The user clicks the "Connect Wallet" button, which is wired to a `Launch URL` node \
(eg upon click GET your Bridge app URL at something like, check out the [Prerequisites](https://cryptonauts.gitbook.io/cryptonauts-docs/setup) for more info regarding the Bridge app)

```
https://your.bridge.url/?payload=%7B%22request%22%3A%22connect%22%7D
```

Note: You can pass to a `Print String` node for debugging purposes.

### "Confirm" Clicked

**After the player clicks Confirm in their Wallet.**\
Your Bridge app will invoke the Authentication Response Call Back to your Game. \
Your Game client needs to be Listening for the Call Back, handling the Authentication Response.

{% hint style="warning" %}
Your Bridge App requires Your Game client to be running a Listening Server (via the BlueprintHttpServer plugin) in order to handle your players authentication response call backs.
{% endhint %}

<figure><img src="https://873068673-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhHL6KhJKtaBfJbxztqID%2Fuploads%2FwTWF1YtyO28THqlKynbt%2Fimage.png?alt=media&#x26;token=177f7add-d4fc-401d-a091-c78c1bedcb25" alt=""><figcaption></figcaption></figure>

Here you can see (top part of the screenshot) in our Event Graph of our `WB_MainMenu`, after our Main Menu is Constructed, we instantiate and set our `HTTP Server` as a variable (this is courtesy of the already installed  [BlueprintHttpServer](https://www.fab.com/listings/8b0025e4-4a98-4461-977d-ebb645def4d7) plugin) and wire it to our two needed routes (`POST` and `OPTIONS`) and wired to our `Listen` node at `127.0.0.1:8080`\
\
During the Authentication Response handling, your game will first need to handle the preflight check. \
This is required and acts as a safety check.\
The preflight request for the http `OPTIONS` is handled by setting the `Headers` \
(variable type Map of Strings)

<figure><img src="https://873068673-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhHL6KhJKtaBfJbxztqID%2Fuploads%2Fh7KBvy265afedc66coD3%2Fimage.png?alt=media&#x26;token=923b98b4-ef4a-4c4c-a60d-619fb5508966" alt=""><figcaption></figcaption></figure>

<figure><img src="https://873068673-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhHL6KhJKtaBfJbxztqID%2Fuploads%2FbS29i1FrrLw1FFBCFP9n%2Fimage.png?alt=media&#x26;token=64816175-a1bb-4d95-9947-df527001b479" alt=""><figcaption></figcaption></figure>

Next handle the `POST` where we can extract the users session details, such as the\
`userSession.loadUserData.profile.stxAddress.mainnet`  from our body `payload`\
Storing and using the `mainnet` address as a game variable.  \
(see [Player BNS](https://cryptonauts.gitbook.io/cryptonauts-docs/auth/bns) for more information regarding storing and making use of the players `mainnet` address)

{% hint style="info" %}
See the [Video Demo](https://cryptonauts.gitbook.io/cryptonauts-docs/auth/video-demo) for Example of the [Player UX ](https://cryptonauts.gitbook.io/cryptonauts-docs/auth/ux) for when the Player Connects their Wallet
{% endhint %}
