void Start() { // Initialize RPC & Websocket nanoManager = gameObject.AddComponent <NanoManager>(); nanoManager.rpcURL = "http://95.216.164.23:28103"; // Update this url to point to your JSON-RPC server nanoManager.defaultRep = defaultRep; nanoWebsocket = gameObject.AddComponent <NanoWebSocket>(); nanoWebsocket.url = "ws://95.216.164.23:28104"; // Update this url to point to your websocket server nanoManager.Websocket = nanoWebsocket; Debug.Log("Private key files located at: " + Path.Combine(Application.persistentDataPath, "Nano")); // Update QR codes for arcade arcadePrivateKey = NanoUtils.ByteArrayToHexString(NanoUtils.GeneratePrivateKey()); nanoManager.AddOnWebsocketConnectListener((bool isError, bool isReconnect) => { // Called when the connection is successfully opened (or failed), it will automatically keep trying to connect if there is a failure if (!isError) { nanoManager.ListenForPaymentWaitConfirmation(NanoUtils.PrivateKeyToAddress(arcadePrivateKey), new NanoAmount("1000000000000000000000000"), true, (error) => { if (!error) { PayArcadeUI.text = "Paid!"; // Wait until the account has a balance StartCoroutine(PaidArcadeHandler()); } else { Debug.Log("Error with payment"); } }); Debug.Log("Successfully connected to websocket!!"); } else { Debug.Log("Failed to connect to websocket!!"); } }); nanoManager.AddConfirmationListener((websocketConfirmationResponse) => { Debug.Log("Confirmation received"); string output = ""; var block = websocketConfirmationResponse.message.block; output += "type: " + block.type + "\n"; output += "account: " + block.account + "\n"; output += "previous: " + block.previous + "\n"; output += "representative: " + block.representative + "\n"; output += "balance: " + block.balance + "\n"; output += "link: " + block.link + "\n"; output += "link_as_account: " + block.link_as_account + "\n"; output += "signature: " + block.signature + "\n"; output += "work: " + block.work + "\n"; output += "subtype: " + block.subtype; WebsockConfirmationResponseUI.text = output; }); nanoManager.AddFilteredConfirmationListener((websocketConfirmationResponse) => { Debug.Log("Confirmation received"); }); // Add event listeners for all the buttons CreatePrivateKeyUI.onClick.AddListener(OnClickCreatePrivateKey); NextPrivateKeyUI.onClick.AddListener(OnClickNextPrivateKey); GenerateWorkUI.onClick.AddListener(OnClickGenerateWork); SendNeedsWorkUI.onClick.AddListener(OnClickSendNeedsWork); ReceiveNeedsWorkUI.onClick.AddListener(OnClickReceiveNeedsWork); SendUI.onClick.AddListener(OnClickSend); ReceiveUI.onClick.AddListener(OnClickReceive); SendWaitConfUI.onClick.AddListener(OnClickSendWaitConf); ReceiveWaitConfUI.onClick.AddListener(OnClickReceiveWaitConf); AutomatePocketingUI.onClick.AddListener(OnClickAutomatePocketing); UnautomatePocketingUI.onClick.AddListener(OnClickUnautomatePocketing); ListenAllConfirmationsUI.onClick.AddListener(OnClickListenAllConfirmations); UnlistenAllConfirmationsUI.onClick.AddListener(OnClickUnlistenAllConfirmations); WatchUI.onClick.AddListener(OnClickWatch); UnwatchUI.onClick.AddListener(OnClickUnwatch); var numRawPayToPlay = "1000000000000000000000000"; var qrCodePayAsTexture2D = NanoUtils.GenerateQRCodeTextureWithAmount(10, NanoUtils.PrivateKeyToAddress(arcadePrivateKey), numRawPayToPlay, 10); QRCodePayArcadeUI.sprite = Sprite.Create(qrCodePayAsTexture2D, new Rect(0.0f, 0.0f, qrCodePayAsTexture2D.width, qrCodePayAsTexture2D.height), new Vector2(0.5f, 0.5f)); watcherPrivateKey = NanoUtils.ByteArrayToHexString(NanoUtils.GeneratePrivateKey()); OnClickNextPrivateKey(); }