/// <param name="network">The ethereum network that the transaction is for (ETH/ETC mainnet or testnet)</param> /// <param name="to">The (hex-encoded) address to send the transaction to</param> /// <param name="value">The (hex-encoded) number of wei to send with this transaction</param> /// <param name="data">The (hex-encoded) string of extra data to include with this transaction</param> /// <param name="gasPrice">The (hex-encoded) gas price in gwei to pay. If not supplied, this will be estimated automatically</param> /// <param name="gas">The (hex-encoded) gas limit for this transaction. If not supplied, this will be estimated automatically</param> public async Task <ApiResponse <PublicBlockchainTransactionResponse> > CreateEthereumTransaction(EthereumNetwork?network, string to, string value, string data, string gasPrice, string gas) { if (network == null) { throw new FailureByDesignException(FailureCode.PARAM_ERROR, "Parameter `network` is required"); } if (string.IsNullOrWhiteSpace(to)) { throw new FailureByDesignException(FailureCode.PARAM_ERROR, "Parameter `to` is required"); } if (string.IsNullOrWhiteSpace(value)) { throw new FailureByDesignException(FailureCode.PARAM_ERROR, "Parameter `value` is required"); } var body = new EthereumTransactionRequest { Network = (EthereumNetwork)network, Transaction = new EthereumTransaction { To = to, Value = value, Data = data, GasPrice = gasPrice, Gas = gas } }; return(await _httpService.PostAsync <PublicBlockchainTransactionResponse>("/public-blockchain-transaction", body)); }
public async Task CreateEthereumTransaction_CallswithCorrectParams_Test() { var request = new EthereumTransactionRequest { Network = EthereumNetwork.ETC_MAINNET, Transaction = new EthereumTransaction { To = "0x0000000000000000000000000000000000000000", Value = "0x0", Data = "0x222", GasPrice = "0x222", Gas = "0x333" } }; await _dragonchainClient.CreateEthereumTransaction(request.Network, request.Transaction.To, request.Transaction.Value, request.Transaction.Data, request.Transaction.GasPrice, request.Transaction.Gas); _httpService.Verify(service => service.PostAsync <PublicBlockchainTransactionResponse>("/public-blockchain-transaction", It.IsAny <EthereumTransactionRequest>(), ""), Times.Once); }