MetaMask / MetaMask/metamask-sdk
Documentation for Unity SDK
- Dominant language
- TypeScript
- Stars
- 338
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
# 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
```csharp
// 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"
}
Contributor guide
Research direction
Start by reviewing the Unity SDK usage around MetamaskUnity.Instance.Wallet.Request and the code sample's requested flows: connection, chain changes, transaction responses, UI states, recovery, exceptions, and performance. Done means an in-depth, easy-to-follow tutorial with clear examples covering the listed common use cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- documentation, game-dev
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100