public async Task <string> IssueTokensAsync(string externalTokenAddress, string toAddress, BigInteger amount) { var externalToken = await _tokenRepository.GetAsync(externalTokenAddress); if (externalToken == null) { throw new ClientSideException(ExceptionType.WrongParams, $"External Token With address {externalTokenAddress} does not exist!"); } //0x2dcc0430f6b9a40fd54f7d99f8a73b7d2d84b1fa var initialSupply = BigInteger.Parse(externalToken.InitialSupply); if (initialSupply != 0) { BigInteger balance = await _ercInterfaceService.GetBalanceForExternalTokenAsync(_settings.EthereumMainAccount, externalTokenAddress); if (balance < amount) { string message = $"Can't issue more tokens. Current balance is {balance}, issue amount is {amount}."; await _logger.WriteInfoAsync("ExternalTokenService", "IssueTokens", "", message, DateTime.UtcNow); throw new ClientSideException(ExceptionType.WrongParams, message); } } string trHash = await _ercInterfaceService.Transfer(externalTokenAddress, _settings.EthereumMainAccount, toAddress, amount); await _logger.WriteInfoAsync("ExternalTokenService", "IssueTokens", "", $"Issued to address {toAddress} {amount.ToString()} tokens from {externalTokenAddress}", DateTime.UtcNow); return(trHash); }
public async Task SendTokensAsync() { var transferHash = await _ercService.Transfer(_externalTokenAddress, _settings.EthereumMainAccount, "0x46Ea3e8d85A06cBBd8c6a491a09409f5B59BEa28", 20000); }