Beispiel #1
0
        public async Task <string> SignAndSendRawTransaction(Nethereum.Signer.Transaction transaction)
        {
            transaction.Sign(new EthECKey(_sender_private_key.HexToByteArray(), isPrivate: true));
            string signed_transaction_data = transaction.GetRLPEncoded().ToHex();
            string tx_hash = await _web3geth.Eth.Transactions.SendRawTransaction.SendRequestAsync(signed_transaction_data);

            return(tx_hash);
        }
        private string SignRawTransaction(string trHex, string privateKey)
        {
            var transaction = new Nethereum.Signer.Transaction(trHex.HexToByteArray());
            var secret      = new EthECKey(privateKey);

            transaction.Sign(secret);

            string signedHex = transaction.GetRLPEncoded().ToHex();

            return(signedHex);
        }
Beispiel #3
0
        public string SignTransaction(
            string transactionContext,
            string privateKey)
        {
            using (var eventHolder = _telemetryClient.StartEvent("TransactionSigned"))
            {
                try
                {
                    var transactionBytes = transactionContext.HexToByteArray();
                    var transactionDto   = MessagePackSerializer.Deserialize <UnsignedTransaction>(transactionBytes);

                    var transaction = new NethereumTransaction
                                      (
                        to: transactionDto.To,
                        amount: transactionDto.Amount,
                        nonce: transactionDto.Nonce,
                        gasPrice: transactionDto.GasPrice,
                        gasLimit: transactionDto.GasAmount,
                        data: null
                                      );

                    transaction.Sign
                    (
                        key: new EthECKey(privateKey)
                    );

                    return(transaction
                           .GetRLPEncoded()
                           .ToHex(prefix: true));
                }
                catch (Exception)
                {
                    eventHolder.TrackFailure("TransactionSigningFailed");

                    throw;
                }
            }
        }
 private string SignTransaction(byte[] privateKey, Transaction transaction)
 {
     transaction.Sign(new EthECKey(privateKey, true));
     return(transaction.GetRLPEncoded().ToHex());
 }