2021Year

How to read and write YAML in Rust with Serde

In this article, we will learn how to read and write YAML files in Rust with the Serde framework. Being able to read YAML files enables you to, for example, use YAML files as configuration files for your projects. This article will not be very in-depth, just a simple example of how to read and write YAML data from a file. The full code for this article can be found on my GitHub. Prerequisites Some understanding of Rust is required. Familiarity with YAML and its structure is also a plus. Creating the project and dependencies Let’s create the project and…

Binance API crypto transaction with Rust: how to

In this article, we are going to learn how to do a buy transaction of crypto with the Binance API. As usual, we will be using the rust programming language. The full project’s repository can be found on my GitHub. I also have another article related to the Binance API: Easily connect to Binance WebSocket streams with Rust Prerequisites To be able to follow this article you should have: Rust installed Some familiarity with Rust and programming against a REST API is helpful. A Binance account. Verification on your Binance account so that you can create an API key. To…

Crypto triangle arbitrage dashboard, part 3: how to add logging

Logging to a storage medium is useful for troubleshooting and analysis when any note-worthy events have occurred. In this article, we will do a quick update to the code base we created in part 1: Crypto triangle arbitrage dashboard: how to, part 1 to add logging to a file for our rust backend. We will add logging to stdout and a file making use of the log4rs crate. For details on how to use log4rs please check out my article about basic file logging with log4rs. Prerequisites Since we are updating the existing code base for the crypto triangle arbitrage…

Crypto triangle arbitrage: how to part 2: frontend

In this article, we will create a quick and dirty crypto triangle arbitrage dashboard frontend with React, to display the triangle arbitrage calculation results and related data. The dashboard will connect to our backend, described in the article: Crypto triangle arbitrage dashboard: how to, part 1, using a WebSocket connection. Then, the triangle arbitrage data received from the backend will be displayed in a simple table. The completed React project can be found on my GitHub: here. Prerequisites The following is required to be able to follow the article and run the frontend and receive data: The completed code project…

Basic how to log to a file in Rust with log4rs

In this article, we will take look at how you can use and configure log4rs to log to a file in your Rust program. Specifically, we will look at some of the options using YAML to configure the logging. What is log4rs From the crate description: “log4rs is a highly configurable logging framework modeled after Java’s Logback and log4j libraries.” For the log4rs crate’s page click here. Why log4rs What is good about log4rs? It offers an easy way to log to a file and it is highly configurable using a YAML config file, as well as through code. However,…

Rust Web3 connect to Ethereum blockchain: how to

In this article for semi-beginners, we are going to learn how to connect to Ethereum with the web3 crate and Rust. We will connect using a WebSocket and then retrieve the balance of our account. Finally, we will use a token smart contract to retrieve information about the token. Please note that we will be using the Rinkeby test network for our interactions. So, if an address for a smart contract or token doesn’t seem to work, make sure that you are using the Rinkeby network. Please look at my GitHub for the full project: rust-web3-basics-tutorial. Please also see this…

Easy to set up Ethereum connection and wallet

In this short article, we look at an option for an easy way to set up an Ethereum node connection and a wallet. We will also look at how to get test Eth for testing purposes. These are the things we need to test and use the applications that interact with the Ethereum blockchain. Which we will develop in other articles. The easiest way is to use services and apps. In this article, we will look at infura.io for Ethereum node connections and metamask for wallets. The information in this post is a prerequisite to follow my article on Rust…

Crypto triangle arbitrage dashboard: how to, part 1

This article is part 1 of a series that will explain how to build a crypto triangle arbitrage dashboard using Rust and React. In this part 1, we will build the backend for the triangle arbitrage dashboard. The backend will gather data about trades for 3 coin pairs from the Binance WebSocket API. Then, it will calculate potential profits if we were to trade the pairs in sequence. Triangle arbitrage attempts to take advantage of price discrepancies between 3 assets that form a triangle on the same exchange. An example trade would be: BTC -> ETH -> BNB -> BTC.…

Warp data update loop: easy how to

What does “Rust Warp data update loop” mean? This article will describe how to create an infinite loop that sends data to clients connected to your WebSocket server in a thread separate from the main thread. This is useful when you want to build a system that periodically retrieves data from one or more sources and then needs to actively push that data to your client application. For example, a frontend dashboard that displays the data. The completed code project can be found on my GitHub, click here. This article will use the project from the following article: Rust Warp…

Rust Warp WebSocket server: learn how to now

In this article we will build a WebSocket server with Rust, using the warp framework. We will slowly go through the code building a simple version at first, and then add a bit more functionality to it. At the end of this article, we will be able to receive messages from the client and send something back in response. We will use this project as a base for future articles to build upon. We add a continuous data update loop to this project in the follow-up article Warp data update loop: easy how to. The repository with the complete Rust…