private long GetBalance(GetBalanceInput input) { ValidateContractState(State.TokenContract, State.TokenContractSystemName.Value); var output = State.TokenContract.GetBalance.Call(input); return(output.Balance); }
public async Task <Transaction> GenerateTransferTransactionAsync() { var chain = await BlockchainService.GetChainAsync(); var tokenContractAddress = await _smartContractAddressService.GetAddressByContractNameAsync(new ChainContext { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, TokenSmartContractAddressNameProvider.StringName); var getBalanceInput = new GetBalanceInput { Owner = Address.FromPublicKey(CryptoHelper.GenerateKeyPair().PublicKey), Symbol = _nativeSymbol }; var transaction = new Transaction { From = await _accountService.GetAccountAsync(), To = tokenContractAddress, MethodName = nameof(TokenContractContainer.TokenContractStub.GetBalance), Params = getBalanceInput.ToByteString(), RefBlockNumber = chain.BestChainHeight, RefBlockPrefix = BlockHelper.GetRefBlockPrefix(chain.BestChainHash) }; var sig = await _accountService.SignAsync(transaction.GetHash().ToByteArray()); transaction.Signature = ByteString.CopyFrom(sig); return(transaction); }
public override GetBalanceOutput GetBalance(GetBalanceInput input) { return(new GetBalanceOutput() { Symbol = input.Symbol, Owner = input.Owner, Balance = State.Balances[input.Owner][input.Symbol] }); }
public override GetBalanceOutput GetBalance(GetBalanceInput input) { return(new GetBalanceOutput() { Symbol = input.Symbol, Owner = input.Owner, Balance = GetBalance(input.Owner, input.Symbol) }); }