Blog

Rust

How to build a REST API server with Rust and warp

In this tutorial, we are going to build a simple Rust REST API using the warp crate. We will learn how to handle simple create, read, update, and delete operations on an in-memory “database”. This tutorial has some similarities with an earlier tutorial that was also using warp. The full code example for this tutorial can be found on my GitHub: here. I also have an article explaining how to implement authentication with warp and JSON Web Tokens: JWT security for a Rust REST API: how to. If you are interested in using WebSockets with warp give it a read:…

How to connect to a Azure Kubernetes Service

This article is about how to connect to a Azure Kubernetes Service (AKS) cluster. We will look at the steps from installing the required tools to logging in to Azure using the terminal to exploring the AKS cluster to get information using a few simple command line commands. This article is aimed at Linux based systems. Prerequisites Please have an Azure account ready to follow along with. We also need to be able to access this account from the system we run the commands from. We are also assuming that there is an existing AKS cluster we want to connect…

What is Docker and why is it used: quick primer

This article is a quick primer on Docker for those who have heard of it but have never actually worked with it. Even if you have some experience working with it, this article will provide you with tips or context that will help understand Docker. But also how to use it effectively. Why use Docker In short, Docker makes application development, packaging, and deployment easier. But, why do we need these things to be easier as developers? First, let’s look at some problems that might occur in typical environment without Docker. Applications and their dependencies Each application we develop has…

How to use JWT with Rust: learn the basics here

In this tutorial, we will learn how to use JSON Web Tokens (JWT) with the Rust programming language. We will go over the basics of JWT, the structure of a JWT, how to encode and decode a JWT. After reading this tutorial you will have a good fundamental understanding of how to use JSON Web Tokens. We will use the jsonwebtoken crate for this article. The full code example for this tutorial can be found on my GitHub: here. What is a JWT Before getting into the code, let’s first look at what a JSON Web Token is. Furthermore, why…

How to make backend configurable: crypto arbitrage part 4

We are going to learn how to make our Rust backend configurable using a YAML file. This is part 4 in a series where we build a dashboard displaying crypto triangle arbitrage information. Specifically, we are going to make configurable what streams we subscribe to for coin market data and what triangles we calculate profit for. Other entries in the series: First, Crypto triangle arbitrage dashboard: how to, part 1 Second, Crypto triangle arbitrage: how to part 2: frontend Third, Crypto triangle arbitrage dashboard, part 3: how to add logging This article’s completed code base can be found on my…

How to swap on Uniswap V2 with Rust Web3

In this article, we will go through the steps of how to swap tokens on Uniswap V2 with Rust and Web3. Using the Rust programming language we will connect to the Ethereum (test) network and interact with Uniswap. There are multiple versions of Uniswap, but in this article, we will perform transactions with Uniswap V2. Important: We will use infura.io to get a connection to an Ethereum node for this article. Infura.io will not maintain any private keys on our behalf to sign transactions with. That means we have to sign the transactions ourselves and send a raw transaction. Instead…

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…