private void Start() { // Get balance with EthGetBalanceUnityRequest in WalletManager, using coroutine WalletManager.GetBalance(_address, (balance) => { // When the callback is called, print out the balance on UI text Debug.LogFormat("StaticWalletBalance:Start - EthGetBalanceUnityRequest returned, balance={0}", balance); _balanceUnityRequestText.text = balance.ToString(); }); // Get balance with Web3, using Task and await var t = GetBalanceByWeb3(_address, (balance) => // Put result as var t just to avoid warning in VisualStudio { // When the callback is called, print out the balance on UI text Debug.LogFormat("StaticWalletBalance:Start - Web3 returned, balance={0}", balance); _balanceWeb3Text.text = balance.ToString(); }); }
public void OnImportWalletClick() { OnResetWalletClick(); // We only demo the first wallet, so reset it first before importing try { WalletManager.ImportWallet("Dummy Account Name", _importPasswordInputField.text, _importEncryptedJsonInputField.text); } catch (System.Exception e) { Debug.LogError("Import wallet failed - password mismatch."); _importPublicKeyInputField.text = string.Empty; _importPrivateKeyInputField.text = string.Empty; } // Print out some wallet parameters after import _importPublicKeyInputField.text = WalletManager.CurrentWalletAddress; _importPrivateKeyInputField.text = WalletManager.CurrentWalletPrivateKey; }
public void OnEthTransferClick() { Debug.LogFormat("TransferDemo:OnEthTransferClick - Start transfering {0} ETH.", decimal.Parse(_ethToAmountInputField.text)); WalletManager.Transfer(_ethToAdressInputField.text, decimal.Parse(_ethToAmountInputField.text), (result) => { _ethToResult = result; // Cache it for opening Etherscan _ethToStatusText.text = "Transaction submitted, waiting to be complete. Hash=" + result; // Display UI Debug.Log("TransferDemo:OnEthTransferClick - Transaction submitted, waiting to be complete."); }, () => { Start(); // Update balances _ethToResult = string.Empty; _ethToStatusText.text = "Transaction succeed!"; Debug.Log("TransferDemo:OnEthTransferClick - Transaction succeed!"); }, (exception) => { _ethToStatusText.text = string.Format("Error: {0}", exception.Message); Debug.LogErrorFormat("TransferDemo:OnEthTransferClick - Error: {0}", exception.Message); }); }
public void OnMiningClick() { if (GethManager.isMining) { _buttonText.text = "Start"; var t = GethManager.StopMiner(() => { QueueStatus("Mining stopped."); WalletManager.StopWatchNewBlocks(); }); } else { _buttonText.text = "Stop"; var t = GethManager.StartMiner(() => { QueueStatus("Mining started."); WalletManager.WatchNewBlocks(); }, () => { QueueStatus("<color=red>Mining cannot start, please check if geth is running with the chosen network.</color>"); OnMiningClick(); }); } }
public void OnResetWalletClick() { WalletManager.DeleteWalletDataFile(); WalletManager.LoadWallets(); DisplayCurrentWalletAddress(); // Mannually reset the address in UI }
public void OnWalletAddressClick() { WalletManager.CopyToClipboard(_address); }
public void OnWalletLinkClick() { WalletManager.OpenEtherscanAddress(_address); }