Add or Switch Network

Request

Leveraging EIP-3085, HyperPlay can pass requests to add a custom network, or switch to the appropriate network, for the user’s MetaMask or WalletConnect wallet.

Network information, including a directory of public RPC endpoints, can be found here.

#include "Endpoints/GetAccounts.h"
#include "HyperPlayUtils.h"

void OnResponse(FString Response, int32 StatusCode)
{
    const bool bWasSuccessful = HyperPlayUtils::StatusCodeIsSuccess(StatusCode);

    UE_LOG(LogTemp, Display, TEXT("GetAccounts Success: %s"), bWasSuccessful ? "true" : "false");
    UE_LOG(LogTemp, Display, TEXT("GetAccounts Response: %s"), *Response);
}

int main(){
FString chainMetadata("{\"chainId\":\"137\",\"chainMetadata\":{\"chainName\":\"Polygon\",\"nativeCurrency\":{\"name\":\"MATIC\",\"symbol\":\"MATIC\",\"decimals\":18},\"rpcUrls\":[\"https://polygon-rpc.com\"]}}");
UGetAccounts* GetAccountsInstance = UGetAccounts::GetAccounts(nullptr, 137, chainMetadata);
GetAccountsInstance->GetOnCompletedDelegate().AddRaw(this, &OnResponse);
GetAccountsInstance->Activate();
}

Response

["0x638105AA1B69406560f6428aEFACe3DB9da83c64"]