public UInt256 ReadDepositBalance(Address onBehalfOf, Keccak depositId) { var txData = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.DepositBalanceAbiSig, depositId.Bytes); Transaction transaction = new Transaction(); transaction.Value = 0; transaction.Data = txData; transaction.To = _contractAddress; transaction.SenderAddress = onBehalfOf; transaction.GasLimit = 100000; transaction.GasPrice = 0.GWei(); transaction.Nonce = (UInt256)_blockchainBridge.GetNonce(onBehalfOf); _wallet.Sign(transaction, _blockchainBridge.GetNetworkId()); BlockchainBridge.CallOutput callOutput = _blockchainBridge.Call(_blockchainBridge.Head, transaction); return((callOutput.OutputData ?? new byte[] { 0 }).ToUInt256()); }
public async Task get_nonce_should_invoke_blockchain_bridge_get_nonce() { UInt256 nonce = 1; var address = TestItem.AddressA; _blockchainBridge.GetNonce(address).Returns(nonce); var result = await _ndmBridge.GetNonceAsync(address); _blockchainBridge.Received().GetNonce(address); result.Should().Be(nonce); }
public ResultWrapper <Keccak> eth_sendTransaction(TransactionForRpc transactionForRpc) { try { _readerWriterLockSlim.EnterWriteLock(); Transaction tx = transactionForRpc.ToTransaction(); if (tx.Signature == null) { tx.Nonce = (UInt256)_blockchainBridge.GetNonce(tx.SenderAddress); _blockchainBridge.Sign(tx); } Keccak txHash = _blockchainBridge.SendTransaction(tx); return(ResultWrapper <Keccak> .Success(txHash)); } finally { _readerWriterLockSlim.ExitWriteLock(); } }
public Keccak ClaimRefund(Address onBehalfOf, RefundClaim refundClaim) { byte[] txData = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.ClaimRefundSig, refundClaim.HeaderId.Bytes, refundClaim.Units, refundClaim.Value, refundClaim.ExpiryTime, refundClaim.Pepper, refundClaim.Provider, onBehalfOf); Transaction transaction = new Transaction(); transaction.Value = 0; transaction.Data = txData; transaction.To = new Address(_ndmConfig.ContractAddress); transaction.SenderAddress = onBehalfOf; transaction.GasLimit = 90000; // check transaction.GasPrice = 20.GWei(); transaction.Nonce = (UInt256)_blockchainBridge.GetNonce(onBehalfOf); _wallet.Sign(transaction, _blockchainBridge.GetNetworkId()); if (_logger.IsInfo) { _logger.Info($"Sending a refund claim transaction for {refundClaim.DepositId} to be refunded to {refundClaim.RefundTo}"); } return(_blockchainBridge.SendTransaction(transaction)); }
public ResultWrapper <Keccak> eth_sendTransaction(TransactionForRpc transactionForRpc) { Transaction tx = transactionForRpc.ToTransaction(); if (tx.Signature == null) { tx.Nonce = _blockchainBridge.GetNonce(tx.SenderAddress); _blockchainBridge.Sign(tx); } Keccak txHash = _blockchainBridge.SendTransaction(tx, true); return(ResultWrapper <Keccak> .Success(txHash)); }
private ResultWrapper <Quantity> GetAccountNonce(Address address, BlockParameter blockParameter) { if (blockParameter.Type == BlockParameterType.Pending) { var nonce = _blockchainBridge.GetNonce(address); return(ResultWrapper <Quantity> .Success(new Quantity(nonce))); } var block = GetBlock(blockParameter); if (block.Result.ResultType == ResultType.Failure) { return(ResultWrapper <Quantity> .Fail(block.Result.Error)); } return(GetAccountNonce(address, block.Data.Header.StateRoot)); }
public Task <UInt256> GetNonceAsync(Address address) => Task.FromResult(_blockchainBridge.GetNonce(address));