Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for Unity SDK #815

Open
helgi-outerlynx opened this issue Apr 18, 2024 · 0 comments
Open

Documentation for Unity SDK #815

helgi-outerlynx opened this issue Apr 18, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@helgi-outerlynx
Copy link

helgi-outerlynx commented Apr 18, 2024

Feature Request

In depth tutorial for the Unity SDK on how to set up Metamask, how to get the results of your requests in a easy to follow structure and interactions with UI elements based on this (ex. Buttons become inactive when sending a transaction request, and display "Success" or "Fail" depending on how the transaction went)

Why it is needed

It's nearly impossible for a developer to reliably build features around this SDK without looking through a lot of code and trying to understand everything about how this SDK works. I know because I'm building an app that heavily relies on this SDK and it's been very difficult not having any official documentation that illustrates anything about how this SDK works and how to use it.

Possible implementation

Simple clear code examples of common use cases which include:

  • Setting up the metamask connection
  • Changing user's chain
  • Adding a new chain to metamask
  • Getting responses from sent transactions
  • Handling UI when sending multiple responses
  • Reliably restarting the connection in cases where the MM app becomes unresponsive
  • Handling exceptions and preventing crashes
  • Explaining how to prevent performance issues (memory leaks etc.)

Code sample

// Switch the user's chain
bool SwitchChain(string chainIdHex){

  var parameters = new {
     chainId = chainIdHex
  }

  var request = new {
     // standard json rpc method. do not change
     method = "wallet_switchEthereumChain"
     params= new [] {parameters}
  }

// make sure user has the chain in their wallet
  var addChainRes = await AddChain(chainIdHex);
  
  // (example code, i know it doesnt work like this. I don't know how it actually works tho...)
  if(res.response.status == "rejected)
  {return}
  
  
  var res = await MetamaskUnity.Instance.Wallet.Request(request);
  
  return res.response.status != "rejected"
}
@helgi-outerlynx helgi-outerlynx added the enhancement New feature or request label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant