For the complete documentation index, see llms.txt. This page is also available as Markdown.

Get Accounts

Request

Get the user's currently selected address

Note that HyperPlay currently supports a single globally selected account during its connection flow. In the future, multiple account addresses will be supported.

curl --location --request POST 'localhost:9680/rpc' \
--header 'Content-Type: application/json' \
--data-raw '{
   "request":{
      "method":"eth_accounts"
   },
   "chain":{
      "chainId":"1"
   }
}'
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class GetAccounts: MonoBehaviour
{
    void Start()
    {
        StartCoroutine(Accounts());
    }

    private IEnumerator Accounts()
    {
        string jsonString = "{\"request\":{\"method\":\"eth_accounts\"},\"chain\":{\"chainId\":\"5\"}}";
        byte[] jsonBytes = System.Text.Encoding.UTF8.GetBytes(jsonString);

        UnityWebRequest request = new UnityWebRequest("localhost:9680/rpc", "POST");
        request.uploadHandler = new UploadHandlerRaw(jsonBytes);
        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        yield return request.SendWebRequest();
        Debug.Log(request.error);
        Debug.Log(request.downloadHandler.text);
    }
}

If you have the HyperPlay plugin installed, copy and paste the following into a Blueprint Graph.

Response

["0x638105aa1b69406560f6428aeface3db9da83c64"]
FString("0x638105aa1b69406560f6428aeface3db9da83c64")

Errors will have an HTTP response status 500-599

{
  "message": "error description here"
}

Last updated