Royce  Reinger

Royce Reinger

1663817795

10 Popular Rust Libraries for Cryptocurrencies

In today's post we will learn about 10 Popular Rust Libraries for Cryptocurrencies.

What is Cryptocurrency?

A cryptocurrency is a digital or virtual currency that is secured by cryptography, which makes it nearly impossible to counterfeit or double-spend. Many cryptocurrencies are decentralized networks based on blockchain technology—a distributed ledger enforced by a disparate network of computers.

A defining feature of cryptocurrencies is that they are generally not issued by any central authority, rendering them theoretically immune to government interference or manipulation.

Table of contents:

  • Akula - Rust Ethereum Execution Layer (EL) Client (WIP)
  • ETK - etk is a collection of tools for writing, reading, and analyzing EVM bytecode.
  • ChainX - Fully Decentralized Interchain Crypto Asset Management on Polkadot.
  • CITA - A high performance blockchain kernel for enterprise users.
  • Coinbase-pro-rs - Coinbase pro client in Rust, supports sync/async/websocket.
  • Diem - Diem’s mission is to enable a simple global currency and financial infrastructure that empowers billions of people.
  • Electrumrs - An efficient re-implementation of Electrum Server in Rust.
  • Ethabi - Encode and decode smart contract invocations.
  • Ethaddrgen - Custom Ethereum vanity address generator made in Rust.
  • Ethers-rs - Complete Ethereum & Celo library and wallet implementation in Rust.

1 - Akula:

Rust Ethereum Execution Layer (EL) Client (WIP)

Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture.

Why run Akula?

Look at Mgas/s.

Installation

Installation instructions available on our website.

View on Github

2 - ETK:

etk is a collection of tools for writing, reading, and analyzing EVM bytecode.

Quickstart

Installation

etk requires the latest rustc from the stable channel.

cargo install --features cli etk-asm etk-dasm

Project Templates

Syntax Highlighting

Usage

contract.etk:

push1 42
push1 13
add
pop
$ eas contract.etk out.hex
$ disease --hex-file out.hex
   0:   push1 0x2a
   2:   push1 0x0d
   4:   add
   5:   pop

Dependencies

ecfg requires z3 to build Ubuntu Installation Instructions (example):

sudo apt-get update -y
sudo apt-get install -y z3
sudo apt-get install -y libz3-dev

Check the system logs to confirm that there are no related errors.

Documentation

The etk book is the most comprehensive guide to using etk.

There are also several examples in the etk-asm/tests/asm directory. For further questions, join us on Telegram.

View on Github

3 - ChainX:

Fully Decentralized Interchain Crypto Asset Management on Polkadot.

ChainX is a community-driven project built on the next-generation blockchain framework substrate, the largest Layer-2 network of Bitcoin using the Light-client protocol with smart contract support, spawn as the third relay chain besides Polkadot/Kusama. SherpaX and MiniX will be added as a parachain.

Based on the LayerZero protocol, the EVM Layer2 ecology on ChainX can share the liquidity of the EVM ecology such as ETH/BSC, and the POW payment coin such as BTC/DogeCoin can share the DAPP ecology of the EVM. light white paper. website

The Fragmented Web3 Crypto World

There have always been many problems in the crypto world, but there has never been a shortage of reforms and innovations.

  • In order to solve the payment performance and scalability problems of BTC, various altcoins such as Dogecoin, LTC, and BCH have been introduced.
  • In order to solve the problems of too expensive gas fees in Ethereum and the scalability of dapps, people have successively developed public chains such as BSC, EOS, Polkadot, and Avalanche, which now seem to have a wide users.

However, the establishment of dapps on these mainstream public chains still faces some problems: the ecosystems of different public chains are separated from each other, and the isolation will disperse the value, until the value returns to 0, the aggregation can accumulate the value, making the value like The piles of wood are piled higher and higher. Also, we cannot exchange tokens on pancakeswap with those on Uniswap because they come from different ecosystems. This will prevent DEXs from having as much liquidity as CEXs. But we must embrace DEXs, because we all know that decentralization is the fundamental attribute and future of the encrypted world, and the meaning of encryption algorithms and even the whole web3 world is decentralization.

Based on this, ChainX, the layer 2 network of Bitcoin, will be committed to solving the above problems and aggregating these divided communities and ecology.

How ChainX solves the above problems

To solve the scalability problem of isolated POW tokens such as Bitcoin and Dogecoin

First, we adopted the mode of light node + multi-centralized hosting (integrated with Taproot aggregated signature + MAST contract + Signal distributed computing protocol). Then, we will adopt the on chain lightning network model to completely solve the scalability problem of POW tokens such as BTC in a completely decentralized way.

To solve the isolation problem of EVM public chains such as ETH/BSC

There are already many solutions for the decentralized cross-chain between EVM chains. We will absorb the LayerZero protocol to realize the cross-chain between decentralized EVM chains.

Later, an aggregation protocol will be deployed on ChainX EVM, so that our DEX can unify liquidity across platforms and chains: for example, pools on UniSwap and pools on PancakeSwap can share liquidity.

In addition, ChainX will realize the consistent mapping between ENS and other various public chain domain name systems. For example, the CID of ComingChat can be mapped with ENS, and ENS can be mapped with BTC addresses.

Aggregation and unification are eternal themes in the crypto world. Aggregation can make the crypto world closer and make web3 competitive enough to replace the web2 world. At the same time, aggregation also prevents LTC, BCH and other DAPP ecologically unprosperous communities from slowly going silent, and the prosperous EVM ecology will also become more prosperous because of aggregation.

ChainX Ecological Project:

  • ComingChat:Integrated web3 portal for encrypted social, digital identity, NFT, digital wallet, smart contract platform portal and other functions. Committed to being a secure and trusted web3 portal. Combining decentralized encryption algorithms and blockchain knowledge to solve trusted information transmission and asset management problems.
  • SherpaX: ChainX's EVM & WASM Smart Contract Parachain.
  • MiniX: ChainX's digital identity, NFT, reputation system parachain.
  • SoSwap: Omni-chain DEX, a distributed financial platform dedicated to allowing multiple chains to share liquidity.
  • ComFuture: Digital identity, NFT creation auction trading platform.
  • USB: The decentralized expansion of BTC that allows BTC and any EVM ecological chain to be integrated with each other.

The crypto world is not perfect, but ChainX is working hard to make it better and better.

Please refer to the docs for building and developing on ChainX platform.

View on Github

4 - CITA:

A high performance blockchain kernel for enterprise users.

What is CITA

CITA is a fast and scalable blockchain kernel for enterprises. CITA supports both native contract and EVM contract, by which enterprise users can build their own blockchain applications. CITA has a unique architecture which enables enterprise users to release all their computing resources.

Horizontal scalability: With the microservice architecture, a logical node can be easily scaled to a cluster of servers. Node administrators can increase system capacity simply by adding more PC servers on high load. The administrator can even use dedicated servers to provide services for hot-spot accounts. Outside one node's boundary, nodes communicate with each other using P2P network; inside each node, microservices communicate with each other by messaging queue.

Customizable and Pluggable Components: CITA's microservices are loosely coupled and their communications are only via the message queue. Hence, it‘s flexible to improve current components with better algorithms (such as new consensus algorithms) or more appropriate technical solutions (such as new DBs or new privacy solutions). Moreover, business logic is extremely complicated in enterprise applications. With CITA, you can easily customize your blockchain with the certain feature to fit your own business requirements.

High Performance: In CITA, consensus and transaction execution are decoupled as separate microservices. The consensus service is only responsible for transaction ordering, which can finish independently before transaction execution, thus increase transaction processing performance. In additional, CITA also includes lots of other optimizations to fully utilize multi-cores and multi-servers' computing power. To this end, it utilizes the Rust language, a hybrid imperative/OO/functional language with an emphasis on efficiency.

Resiliency and Reliability: CITA provides tools to backup blockchain data by taking snapshot, which can help you to resync the blockchain data in a short time. And through Rust’s language-level memory and thread guarantees and a disciplined approach to exception-handling, we can state with a high degree of certainty that our code cannot crash, hang or bomb-out unexpectedly.

Compatibility: CITA supports the use of Solidity, Go, and Rust to develop smart contracts. It also supports all Ethereum development tools (Truffle, Zeppelin, Remix, etc.).

Chain Interoperability: We perceive that independent blockchains are constantly emerging nowadays and even more in the future. How do these chains interoperate with each other to form blockchain network? CITA Support cross-chain communication by providing a simple cross-chain protocol currently. More explorations are undertaking in CITA, aiming to amplify the value of applications running on the various chains.

Engineering Experience: There're many CITA networks running in banks, payment and insurance production environment, with Rivtower or CITA Integration Provider's technical support. CITA has accumulated a lot of engineering experience.

Whitepaper

For more details please check the white paper.

Document

API/SDK

CITA supports JSON-RPC and WebSocket (experimental) API/v1.

For CITA API/v1, You can use any HTTP client, or following SDKs:

View on Github

5 - Coinbase-pro-rs:

Coinbase pro client in Rust, supports sync/async/websocket.

Features

  • private and public API
  • sync and async support
  • websocket-feed support

Examples

Cargo.toml:

[dependencies]
coinbase-pro-rs = "0.7.1"

Async

use hyper::rt::Future;
use coinbase_pro_rs::{Public, ASync, SANDBOX_URL};

fn main() {
    let client: Public<ASync> = Public::new_with_keep_alive(SANDBOX_URL, false);
    // if keep_alive is not disables - tokio::run will hold the connection without exiting the example
    let f = client.get_time()
        .map_err(|_| ())
        .and_then(|time| {
            println!("Coinbase.time: {}", time.iso);
            Ok(())
        });

    tokio::run(f); // waiting for tokio
}

Sync

use coinbase_pro_rs::{Public, Sync, SANDBOX_URL};

fn main() {
   let client: Public<Sync> = Public::new(SANDBOX_URL);
   let time = client.get_time().unwrap();
   println!("Coinbase.time: {}", time.iso);
}

Websocket

use futures::{Future, Stream};
use coinbase_pro_rs::{WSFeed, WS_SANDBOX_URL};
use coinbase_pro_rs::structs::wsfeed::*;

fn main() {
    let stream = WSFeed::connect(WS_SANDBOX_URL,
        &["BTC-USD"], &[ChannelType::Heartbeat])
        .await
        .unwrap();

    let f = stream
        .take(10)
        .for_each(|msg| {
        match msg {
            Message::Heartbeat {sequence, last_trade_id, time, ..} => println!("{}: seq:{} id{}",
                                                                               time, sequence, last_trade_id),
            Message::Error {message} => println!("Error: {}", message),
            Message::InternalError(_) => panic!("internal_error"),
            other => println!("{:?}", other)
        }
        Ok(())
    });

    tokio::run(f.map_err(|_| panic!("stream fail")));
}

Api supported:

  •  SYNC
  •  ASYNC
  •  Websocket-Feed

API

  •  Requests
  •  Pagination
  •  Types
  •  Private
    •  Authentication
    •  Accounts
    •  Orders
    •  Fills
    •  Deposits
      •  List
    •  Withdrawals
      •  List
    •  Payment Methods
    •  Coinbase Accounts
    •  Fees
    •  Reports
    •  User Account
  •  Market Data
    •  Products
    •  Currencies
    •  Time
  •  Websocket Feed
    •  heartbeat
    •  ticker
    •  level2
    •  user
    •  matches
    •  full

View on Github

6 - Diem:

Diem’s mission is to enable a simple global currency and financial infrastructure that empowers billions of people.

Note to Developers

  • Diem Core is a prototype.
  • The APIs are constantly evolving and designed to demonstrate types of functionality. Expect substantial changes before the release.
  • We’ve launched a testnet that is a live demonstration of an early prototype of the Diem Blockchain software.

Getting Started

Learn About Diem

Try Diem Core

Technical Papers

Blog

View on Github

7 - Electrumrs:

An efficient re-implementation of Electrum Server in Rust.

An efficient re-implementation of Electrum Server, inspired by ElectrumX, Electrum Personal Server and bitcoincore-indexd.

The motivation behind this project is to enable a user to self host an Electrum server, with required hardware resources not much beyond those of a full node. The server indexes the entire Bitcoin blockchain, and the resulting index enables fast queries for any given user wallet, allowing the user to keep real-time track of balances and transaction history using the Electrum wallet. Since it runs on the user's own machine, there is no need for the wallet to communicate with external Electrum servers, thus preserving the privacy of the user's addresses and balances.

Usage

Please prefer to use OUR usage guide!

External guides can be out-of-date and have various problems. At least double-check that the guide you're using is actively maintained. If you can't use our guide, please ask about what you don't understand or consider using automated deployments.

Note that this implementation of Electrum server is optimized for personal/small-scale (family/friends) usage. It's a bad idea to run it publicly as it'd expose you to DoS and maybe also other attacks. If you want to run a public server you may be interested in the Blockstream fork of electrs which is better optimized for public usage at the cost of consuming significantly more resources.

Features

  • Supports Electrum protocol v1.4
  • Maintains an index over transaction inputs and outputs, allowing fast balance queries
  • Fast synchronization of the Bitcoin blockchain (~4 hours for ~336GB @ August 2021) using HDD storage.
  • Low index storage overhead (~10%), relying on a local full node for transaction retrieval
  • Efficient mempool tracker (allowing better fee estimation)
  • Low CPU & memory usage (after initial indexing)
  • txindex is not required for the Bitcoin node
  • Uses a single RocksDB database, for better consistency and crash recovery

Altcoins

Altcoins are not supported! Forks of Bitcoin codebase that relax the consensus rules (hard forks) are also not supported.

You may be able to find a fork of electrs that does support them, look around or make your own, just don't file issues/PRs here.

Index database

The database schema is described here.

Logo

Our logo is generously provided by Dominik Průša under the MIT license. Based on the Electrum logo and the Rust language logo.

View on Github

8 - Ethabi:

Encode and decode smart contract invocations.

The ABI, Application Binary Interface, is basically how you call functions in a contract and get data back.

An ABI determines such details as how functions are called and in which binary format information should be passed from one program component to the next...

An Ethereum smart contract is bytecode, EVM, on the Ethereum blockchain. Among the EVM, there could be several functions in a contract. An ABI is necessary so that you can specify which function in the contract to invoke, as well as get a guarantee that the function will return data in the format you are expecting.

Installation

cargo install ethabi-cli

Usage

Ethereum ABI coder.
  Copyright 2016-2017 Parity Technologies (UK) Limited

Usage:
    ethabi encode function <abi-path> <function-name-or-signature> [-p <param>]... [-l | --lenient]
    ethabi encode params [-v <type> <param>]... [-l | --lenient]
    ethabi decode function <abi-path> <function-name-or-signature> <data>
    ethabi decode params [-t <type>]... <data>
    ethabi decode log <abi-path> <event-name-or-signature> [-l <topic>]... <data>
    ethabi -h | --help

Options:
    -h, --help         Display this message and exit.
    -l, --lenient      Allow short representation of input params.

Commands:
    encode             Encode ABI call.
    decode             Decode ABI call result.
    function           Load function from json ABI file.
    params             Specify types of input params inline.
    log                Decode event log.

Examples

ethabi encode params -v bool 1

0000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode params -v bool 1 -v string gavofyork -v bool 0

00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000

--

ethabi encode params -v bool[] [1,0,false]

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

--

ethabi encode params -v '(string,bool,string)' '(test,1,cyborg)'

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004746573740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066379626f72670000000000000000000000000000000000000000000000000000

--

ethabi encode function examples/test.json foo -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

455575780000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json foo(bool) -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

455575780000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json bar(bool) -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

6fae94120000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json bar(string):(uint256) -p 1
[{
	"type":"function",
	"inputs": [{
		"type":"string"
	}],
	"name":"foo",
	"outputs": [{
		"type": "uint256"
	}]
}]

d473a8ed000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000

--

ethabi decode params -t bool 0000000000000000000000000000000000000000000000000000000000000001

bool true

--

ethabi decode params -t bool -t string -t bool 00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000

bool true
string gavofyork
bool false

--

ethabi decode params -t bool[] 00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

bool[] [true,false,false]

--

ethabi decode params -t '(string,bool,string)' 00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000673706972616c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000067175617361720000000000000000000000000000000000000000000000000000```

(string,bool,string) (spiral,true,quasar)

View on Github

9 - Ethaddrgen:

Custom Ethereum vanity address generator made in Rust.

Get a shiny ethereum address and stand out from the crowd!

Disclaimer: Do not use the private key shown in this demo; it's public, strangers could steal your Eth. Never share your private key with anyone. It's your and only your responsibility to keep your private key in secret.

Features

  • Regex support (--regex/-e): Use regex pattern matching
  • Quiet mode (--quiet/-q): Output only the results
  • Stream mode (--stream/-s): Keep outputting results
  • Color settings (--color/-c): Enable/Disable colors
  • Dictionary support: If no patterns are provided as arguments, patterns are read from the standard input

Usage

Download the latest release here. To display usage, run ethaddrgen -h or ethaddrgen --help for a longer version. ethaddrgen expects the last arguments to be patterns. If no patterns are provided as arguments, ethaddrgen reads patterns from the standard input where each pattern is on a separate line.

Examples

Simple example

The following command will look for an address starting with either c0ffee, deadbeef or c0c0a. If you are on Windows, use ethaddrgen.exe instead of ethaddrgen.

ethaddrgen c0ffee deadbeef c0c0a

Regex example

The following command will look for an address starting with 10 letters. If you are on Windows, use ethaddrgen.exe instead of ethaddrgen.

ethaddrgen -e '^[abcdef]{10}'

Note that while supplying multiple regex patterns is supported, it is not recommended to use a large list of regex patterns.

Using pattern lists (dictionaries)

If no patterns are provided as arguments, patterns are read from the standard input. You can provide data to the standard input in various ways, depending on your platform:

  • Windows:
Get-Content patterns.txt | ethaddrgen.exe
  • Unix (macOS/Linux):
cat patterns.txt | ethaddrgen
# or
ethaddrgen < patterns.txt

where the patterns.txt file is a newline-separated list of patterns, for example:

c0ffee
deadbeef
c0c0a

It is not recommended to use large pattern lists with regex, as combining these features significantly decreases performance.

View on Github

10 - Ethers-rs:

Complete Ethereum & Celo library and wallet implementation in Rust.

Extensive documentation and examples are available here.

Alternatively, you may clone the repository and run cd ethers/ && cargo doc --open

You can also run any of the examples by executing: cargo run -p ethers --example <name>

Add ethers-rs to your repository

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs" }

Running the tests

Tests require the following installed:

  1. solc (>=0.8.10). We also recommend using solc-select for more flexibility.
  2. anvil
  3. geth

In addition, it is recommended that you set the ETHERSCAN_API_KEY environment variable for the abigen via Etherscan tests. You can get one here.

EVM-compatible chains support

There are many chains live which are Ethereum JSON-RPC & EVM compatible, but do not yet have support for EIP-2718 Typed Transactions. This means that transactions submitted to them by default in ethers-rs will have invalid serialization. To address that, you must use the legacy feature flag:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["legacy"] }

Polygon support

There is abigen support for Polygon and the Mumbai test network. It is recommended that you set the POLYGONSCAN_API_KEY environment variable. You can get one here.

Avalanche support

There is abigen support for Avalanche and the Fuji test network. It is recommended that you set the SNOWTRACE_API_KEY environment variable. You can get one here.

Celo Support

Celo support is turned on via the feature-flag celo:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["celo"] }

Celo's transactions differ from Ethereum transactions by including 3 new fields:

  • fee_currency: The currency fees are paid in (None for CELO, otherwise it's an Address)
  • gateway_fee_recipient: The address of the fee recipient (None for no gateway fee paid)
  • gateway_fee: Gateway fee amount (None for no gateway fee paid)

The feature flag enables these additional fields in the transaction request builders and in the transactions which are fetched over JSON-RPC.

Features

  •  Ethereum JSON-RPC Client
  •  Interacting and deploying smart contracts
  •  Type safe smart contract bindings code generation
  •  Querying past events
  •  Event monitoring as Streams
  •  ENS as a first class citizen
  •  Celo support
  •  Polygon support
  •  Avalanche support
  •  Websockets / eth_subscribe
  •  Hardware Wallet Support
  •  Parity APIs (tracing, parity_blockWithReceipts)
  •  Geth TxPool API
  •  WASM Bindings (see note)
  •  FFI Bindings (see note)
  •  CLI for common operations

Websockets

Websockets support is turned on via the feature-flag ws:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["ws"] }

Interprocess Communication (IPC)

IPC support is turned on via the feature-flag ipc:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["ipc"] }

View on Github

Thank you for following this article.

Related videos:

Build a cryptocurrency! - Blockchain in Rust 01: Blocks & Hashing

#rust #blockchain #cryptocurrencies 

What is GEEK

Buddha Community

10 Popular Rust Libraries for Cryptocurrencies

Serde Rust: Serialization Framework for Rust

Serde

*Serde is a framework for serializing and deserializing Rust data structures efficiently and generically.*

You may be looking for:

Serde in action

Click to show Cargo.toml. Run this code in the playground.

[dependencies]

# The core APIs, including the Serialize and Deserialize traits. Always
# required when using Serde. The "derive" feature is only required when
# using #[derive(Serialize, Deserialize)] to make Serde work with structs
# and enums defined in your crate.
serde = { version = "1.0", features = ["derive"] }

# Each data format lives in its own crate; the sample code below uses JSON
# but you may be using a different one.
serde_json = "1.0"

 

use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, Debug)]
struct Point {
    x: i32,
    y: i32,
}

fn main() {
    let point = Point { x: 1, y: 2 };

    // Convert the Point to a JSON string.
    let serialized = serde_json::to_string(&point).unwrap();

    // Prints serialized = {"x":1,"y":2}
    println!("serialized = {}", serialized);

    // Convert the JSON string back to a Point.
    let deserialized: Point = serde_json::from_str(&serialized).unwrap();

    // Prints deserialized = Point { x: 1, y: 2 }
    println!("deserialized = {:?}", deserialized);
}

Getting help

Serde is one of the most widely used Rust libraries so any place that Rustaceans congregate will be able to help you out. For chat, consider trying the #rust-questions or #rust-beginners channels of the unofficial community Discord (invite: https://discord.gg/rust-lang-community), the #rust-usage or #beginners channels of the official Rust Project Discord (invite: https://discord.gg/rust-lang), or the #general stream in Zulip. For asynchronous, consider the [rust] tag on StackOverflow, the /r/rust subreddit which has a pinned weekly easy questions post, or the Rust Discourse forum. It's acceptable to file a support issue in this repo but they tend not to get as many eyes as any of the above and may get closed without a response after some time.

Download Details:
Author: serde-rs
Source Code: https://github.com/serde-rs/serde
License: View license

#rust  #rustlang 

Mike doctor

Mike doctor

1624230000

TOP 10 Cryptocurrency to Buy in 2021 (HIGH GROWTH)

In this video, we’re going over the top 10 crypto to invest in for 2021! I’ll go through the extended price history, a brief overview of each coin, and cost analysis. These are the best crypto to buy now!
I’ve done the research, and unfortunately there are hundreds/thousands of bad coins out there. In my opinion, the crypto on this list are reputable, more popular, and better long time holds than many other coins out there. I’ll do a walkthrough of each cryptocurrency and go through the stats. Some of the coins on the list are popular ones liked Bitcoin and Ethereum, and others are much less common like Thorchain (RUNE).

Crypto is definitely a risky investment so please invest at your own risk - I am not a financial advisor so this video should be taken for entertainment purposes only. Do your own due diligence before investing in anything - and I recommend doing an additional hour of research per coin or stock that you are considering.
📺 The video in this post was made by Charlie Chang
The origin of the article: https://www.youtube.com/watch?v=-zzQIeZkU6s
🔺 DISCLAIMER: The article is for information sharing. The content of this video is solely the opinions of the speaker who is not a licensed financial advisor or registered investment advisor. Not investment advice or legal advice.
Cryptocurrency trading is VERY risky. Make sure you understand these risks and that you are responsible for what you do with your money
🔥 If you’re a beginner. I believe the article below will be useful to you ☞ What You Should Know Before Investing in Cryptocurrency - For Beginner
⭐ ⭐ ⭐The project is of interest to the community. Join to Get free ‘GEEK coin’ (GEEKCASH coin)!
☞ **-----CLICK HERE-----**⭐ ⭐ ⭐
Thanks for visiting and watching! Please don’t forget to leave a like, comment and share!

#bitcoin #blockchain #cryptocurrency #top 10 cryptocurrency to buy in 2021 #top cryptocurrency to buy #top 10 cryptocurrency to buy in 2021 (high growth)

Royce  Reinger

Royce Reinger

1663817795

10 Popular Rust Libraries for Cryptocurrencies

In today's post we will learn about 10 Popular Rust Libraries for Cryptocurrencies.

What is Cryptocurrency?

A cryptocurrency is a digital or virtual currency that is secured by cryptography, which makes it nearly impossible to counterfeit or double-spend. Many cryptocurrencies are decentralized networks based on blockchain technology—a distributed ledger enforced by a disparate network of computers.

A defining feature of cryptocurrencies is that they are generally not issued by any central authority, rendering them theoretically immune to government interference or manipulation.

Table of contents:

  • Akula - Rust Ethereum Execution Layer (EL) Client (WIP)
  • ETK - etk is a collection of tools for writing, reading, and analyzing EVM bytecode.
  • ChainX - Fully Decentralized Interchain Crypto Asset Management on Polkadot.
  • CITA - A high performance blockchain kernel for enterprise users.
  • Coinbase-pro-rs - Coinbase pro client in Rust, supports sync/async/websocket.
  • Diem - Diem’s mission is to enable a simple global currency and financial infrastructure that empowers billions of people.
  • Electrumrs - An efficient re-implementation of Electrum Server in Rust.
  • Ethabi - Encode and decode smart contract invocations.
  • Ethaddrgen - Custom Ethereum vanity address generator made in Rust.
  • Ethers-rs - Complete Ethereum & Celo library and wallet implementation in Rust.

1 - Akula:

Rust Ethereum Execution Layer (EL) Client (WIP)

Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture.

Why run Akula?

Look at Mgas/s.

Installation

Installation instructions available on our website.

View on Github

2 - ETK:

etk is a collection of tools for writing, reading, and analyzing EVM bytecode.

Quickstart

Installation

etk requires the latest rustc from the stable channel.

cargo install --features cli etk-asm etk-dasm

Project Templates

Syntax Highlighting

Usage

contract.etk:

push1 42
push1 13
add
pop
$ eas contract.etk out.hex
$ disease --hex-file out.hex
   0:   push1 0x2a
   2:   push1 0x0d
   4:   add
   5:   pop

Dependencies

ecfg requires z3 to build Ubuntu Installation Instructions (example):

sudo apt-get update -y
sudo apt-get install -y z3
sudo apt-get install -y libz3-dev

Check the system logs to confirm that there are no related errors.

Documentation

The etk book is the most comprehensive guide to using etk.

There are also several examples in the etk-asm/tests/asm directory. For further questions, join us on Telegram.

View on Github

3 - ChainX:

Fully Decentralized Interchain Crypto Asset Management on Polkadot.

ChainX is a community-driven project built on the next-generation blockchain framework substrate, the largest Layer-2 network of Bitcoin using the Light-client protocol with smart contract support, spawn as the third relay chain besides Polkadot/Kusama. SherpaX and MiniX will be added as a parachain.

Based on the LayerZero protocol, the EVM Layer2 ecology on ChainX can share the liquidity of the EVM ecology such as ETH/BSC, and the POW payment coin such as BTC/DogeCoin can share the DAPP ecology of the EVM. light white paper. website

The Fragmented Web3 Crypto World

There have always been many problems in the crypto world, but there has never been a shortage of reforms and innovations.

  • In order to solve the payment performance and scalability problems of BTC, various altcoins such as Dogecoin, LTC, and BCH have been introduced.
  • In order to solve the problems of too expensive gas fees in Ethereum and the scalability of dapps, people have successively developed public chains such as BSC, EOS, Polkadot, and Avalanche, which now seem to have a wide users.

However, the establishment of dapps on these mainstream public chains still faces some problems: the ecosystems of different public chains are separated from each other, and the isolation will disperse the value, until the value returns to 0, the aggregation can accumulate the value, making the value like The piles of wood are piled higher and higher. Also, we cannot exchange tokens on pancakeswap with those on Uniswap because they come from different ecosystems. This will prevent DEXs from having as much liquidity as CEXs. But we must embrace DEXs, because we all know that decentralization is the fundamental attribute and future of the encrypted world, and the meaning of encryption algorithms and even the whole web3 world is decentralization.

Based on this, ChainX, the layer 2 network of Bitcoin, will be committed to solving the above problems and aggregating these divided communities and ecology.

How ChainX solves the above problems

To solve the scalability problem of isolated POW tokens such as Bitcoin and Dogecoin

First, we adopted the mode of light node + multi-centralized hosting (integrated with Taproot aggregated signature + MAST contract + Signal distributed computing protocol). Then, we will adopt the on chain lightning network model to completely solve the scalability problem of POW tokens such as BTC in a completely decentralized way.

To solve the isolation problem of EVM public chains such as ETH/BSC

There are already many solutions for the decentralized cross-chain between EVM chains. We will absorb the LayerZero protocol to realize the cross-chain between decentralized EVM chains.

Later, an aggregation protocol will be deployed on ChainX EVM, so that our DEX can unify liquidity across platforms and chains: for example, pools on UniSwap and pools on PancakeSwap can share liquidity.

In addition, ChainX will realize the consistent mapping between ENS and other various public chain domain name systems. For example, the CID of ComingChat can be mapped with ENS, and ENS can be mapped with BTC addresses.

Aggregation and unification are eternal themes in the crypto world. Aggregation can make the crypto world closer and make web3 competitive enough to replace the web2 world. At the same time, aggregation also prevents LTC, BCH and other DAPP ecologically unprosperous communities from slowly going silent, and the prosperous EVM ecology will also become more prosperous because of aggregation.

ChainX Ecological Project:

  • ComingChat:Integrated web3 portal for encrypted social, digital identity, NFT, digital wallet, smart contract platform portal and other functions. Committed to being a secure and trusted web3 portal. Combining decentralized encryption algorithms and blockchain knowledge to solve trusted information transmission and asset management problems.
  • SherpaX: ChainX's EVM & WASM Smart Contract Parachain.
  • MiniX: ChainX's digital identity, NFT, reputation system parachain.
  • SoSwap: Omni-chain DEX, a distributed financial platform dedicated to allowing multiple chains to share liquidity.
  • ComFuture: Digital identity, NFT creation auction trading platform.
  • USB: The decentralized expansion of BTC that allows BTC and any EVM ecological chain to be integrated with each other.

The crypto world is not perfect, but ChainX is working hard to make it better and better.

Please refer to the docs for building and developing on ChainX platform.

View on Github

4 - CITA:

A high performance blockchain kernel for enterprise users.

What is CITA

CITA is a fast and scalable blockchain kernel for enterprises. CITA supports both native contract and EVM contract, by which enterprise users can build their own blockchain applications. CITA has a unique architecture which enables enterprise users to release all their computing resources.

Horizontal scalability: With the microservice architecture, a logical node can be easily scaled to a cluster of servers. Node administrators can increase system capacity simply by adding more PC servers on high load. The administrator can even use dedicated servers to provide services for hot-spot accounts. Outside one node's boundary, nodes communicate with each other using P2P network; inside each node, microservices communicate with each other by messaging queue.

Customizable and Pluggable Components: CITA's microservices are loosely coupled and their communications are only via the message queue. Hence, it‘s flexible to improve current components with better algorithms (such as new consensus algorithms) or more appropriate technical solutions (such as new DBs or new privacy solutions). Moreover, business logic is extremely complicated in enterprise applications. With CITA, you can easily customize your blockchain with the certain feature to fit your own business requirements.

High Performance: In CITA, consensus and transaction execution are decoupled as separate microservices. The consensus service is only responsible for transaction ordering, which can finish independently before transaction execution, thus increase transaction processing performance. In additional, CITA also includes lots of other optimizations to fully utilize multi-cores and multi-servers' computing power. To this end, it utilizes the Rust language, a hybrid imperative/OO/functional language with an emphasis on efficiency.

Resiliency and Reliability: CITA provides tools to backup blockchain data by taking snapshot, which can help you to resync the blockchain data in a short time. And through Rust’s language-level memory and thread guarantees and a disciplined approach to exception-handling, we can state with a high degree of certainty that our code cannot crash, hang or bomb-out unexpectedly.

Compatibility: CITA supports the use of Solidity, Go, and Rust to develop smart contracts. It also supports all Ethereum development tools (Truffle, Zeppelin, Remix, etc.).

Chain Interoperability: We perceive that independent blockchains are constantly emerging nowadays and even more in the future. How do these chains interoperate with each other to form blockchain network? CITA Support cross-chain communication by providing a simple cross-chain protocol currently. More explorations are undertaking in CITA, aiming to amplify the value of applications running on the various chains.

Engineering Experience: There're many CITA networks running in banks, payment and insurance production environment, with Rivtower or CITA Integration Provider's technical support. CITA has accumulated a lot of engineering experience.

Whitepaper

For more details please check the white paper.

Document

API/SDK

CITA supports JSON-RPC and WebSocket (experimental) API/v1.

For CITA API/v1, You can use any HTTP client, or following SDKs:

View on Github

5 - Coinbase-pro-rs:

Coinbase pro client in Rust, supports sync/async/websocket.

Features

  • private and public API
  • sync and async support
  • websocket-feed support

Examples

Cargo.toml:

[dependencies]
coinbase-pro-rs = "0.7.1"

Async

use hyper::rt::Future;
use coinbase_pro_rs::{Public, ASync, SANDBOX_URL};

fn main() {
    let client: Public<ASync> = Public::new_with_keep_alive(SANDBOX_URL, false);
    // if keep_alive is not disables - tokio::run will hold the connection without exiting the example
    let f = client.get_time()
        .map_err(|_| ())
        .and_then(|time| {
            println!("Coinbase.time: {}", time.iso);
            Ok(())
        });

    tokio::run(f); // waiting for tokio
}

Sync

use coinbase_pro_rs::{Public, Sync, SANDBOX_URL};

fn main() {
   let client: Public<Sync> = Public::new(SANDBOX_URL);
   let time = client.get_time().unwrap();
   println!("Coinbase.time: {}", time.iso);
}

Websocket

use futures::{Future, Stream};
use coinbase_pro_rs::{WSFeed, WS_SANDBOX_URL};
use coinbase_pro_rs::structs::wsfeed::*;

fn main() {
    let stream = WSFeed::connect(WS_SANDBOX_URL,
        &["BTC-USD"], &[ChannelType::Heartbeat])
        .await
        .unwrap();

    let f = stream
        .take(10)
        .for_each(|msg| {
        match msg {
            Message::Heartbeat {sequence, last_trade_id, time, ..} => println!("{}: seq:{} id{}",
                                                                               time, sequence, last_trade_id),
            Message::Error {message} => println!("Error: {}", message),
            Message::InternalError(_) => panic!("internal_error"),
            other => println!("{:?}", other)
        }
        Ok(())
    });

    tokio::run(f.map_err(|_| panic!("stream fail")));
}

Api supported:

  •  SYNC
  •  ASYNC
  •  Websocket-Feed

API

  •  Requests
  •  Pagination
  •  Types
  •  Private
    •  Authentication
    •  Accounts
    •  Orders
    •  Fills
    •  Deposits
      •  List
    •  Withdrawals
      •  List
    •  Payment Methods
    •  Coinbase Accounts
    •  Fees
    •  Reports
    •  User Account
  •  Market Data
    •  Products
    •  Currencies
    •  Time
  •  Websocket Feed
    •  heartbeat
    •  ticker
    •  level2
    •  user
    •  matches
    •  full

View on Github

6 - Diem:

Diem’s mission is to enable a simple global currency and financial infrastructure that empowers billions of people.

Note to Developers

  • Diem Core is a prototype.
  • The APIs are constantly evolving and designed to demonstrate types of functionality. Expect substantial changes before the release.
  • We’ve launched a testnet that is a live demonstration of an early prototype of the Diem Blockchain software.

Getting Started

Learn About Diem

Try Diem Core

Technical Papers

Blog

View on Github

7 - Electrumrs:

An efficient re-implementation of Electrum Server in Rust.

An efficient re-implementation of Electrum Server, inspired by ElectrumX, Electrum Personal Server and bitcoincore-indexd.

The motivation behind this project is to enable a user to self host an Electrum server, with required hardware resources not much beyond those of a full node. The server indexes the entire Bitcoin blockchain, and the resulting index enables fast queries for any given user wallet, allowing the user to keep real-time track of balances and transaction history using the Electrum wallet. Since it runs on the user's own machine, there is no need for the wallet to communicate with external Electrum servers, thus preserving the privacy of the user's addresses and balances.

Usage

Please prefer to use OUR usage guide!

External guides can be out-of-date and have various problems. At least double-check that the guide you're using is actively maintained. If you can't use our guide, please ask about what you don't understand or consider using automated deployments.

Note that this implementation of Electrum server is optimized for personal/small-scale (family/friends) usage. It's a bad idea to run it publicly as it'd expose you to DoS and maybe also other attacks. If you want to run a public server you may be interested in the Blockstream fork of electrs which is better optimized for public usage at the cost of consuming significantly more resources.

Features

  • Supports Electrum protocol v1.4
  • Maintains an index over transaction inputs and outputs, allowing fast balance queries
  • Fast synchronization of the Bitcoin blockchain (~4 hours for ~336GB @ August 2021) using HDD storage.
  • Low index storage overhead (~10%), relying on a local full node for transaction retrieval
  • Efficient mempool tracker (allowing better fee estimation)
  • Low CPU & memory usage (after initial indexing)
  • txindex is not required for the Bitcoin node
  • Uses a single RocksDB database, for better consistency and crash recovery

Altcoins

Altcoins are not supported! Forks of Bitcoin codebase that relax the consensus rules (hard forks) are also not supported.

You may be able to find a fork of electrs that does support them, look around or make your own, just don't file issues/PRs here.

Index database

The database schema is described here.

Logo

Our logo is generously provided by Dominik Průša under the MIT license. Based on the Electrum logo and the Rust language logo.

View on Github

8 - Ethabi:

Encode and decode smart contract invocations.

The ABI, Application Binary Interface, is basically how you call functions in a contract and get data back.

An ABI determines such details as how functions are called and in which binary format information should be passed from one program component to the next...

An Ethereum smart contract is bytecode, EVM, on the Ethereum blockchain. Among the EVM, there could be several functions in a contract. An ABI is necessary so that you can specify which function in the contract to invoke, as well as get a guarantee that the function will return data in the format you are expecting.

Installation

cargo install ethabi-cli

Usage

Ethereum ABI coder.
  Copyright 2016-2017 Parity Technologies (UK) Limited

Usage:
    ethabi encode function <abi-path> <function-name-or-signature> [-p <param>]... [-l | --lenient]
    ethabi encode params [-v <type> <param>]... [-l | --lenient]
    ethabi decode function <abi-path> <function-name-or-signature> <data>
    ethabi decode params [-t <type>]... <data>
    ethabi decode log <abi-path> <event-name-or-signature> [-l <topic>]... <data>
    ethabi -h | --help

Options:
    -h, --help         Display this message and exit.
    -l, --lenient      Allow short representation of input params.

Commands:
    encode             Encode ABI call.
    decode             Decode ABI call result.
    function           Load function from json ABI file.
    params             Specify types of input params inline.
    log                Decode event log.

Examples

ethabi encode params -v bool 1

0000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode params -v bool 1 -v string gavofyork -v bool 0

00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000

--

ethabi encode params -v bool[] [1,0,false]

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

--

ethabi encode params -v '(string,bool,string)' '(test,1,cyborg)'

00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004746573740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066379626f72670000000000000000000000000000000000000000000000000000

--

ethabi encode function examples/test.json foo -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

455575780000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json foo(bool) -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

455575780000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json bar(bool) -p 1
[{
	"type":"function",
	"inputs": [{
		"name":"a",
		"type":"bool"
	}],
	"name":"foo",
	"outputs": []
}]

6fae94120000000000000000000000000000000000000000000000000000000000000001

--

ethabi encode function examples/test.json bar(string):(uint256) -p 1
[{
	"type":"function",
	"inputs": [{
		"type":"string"
	}],
	"name":"foo",
	"outputs": [{
		"type": "uint256"
	}]
}]

d473a8ed000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000013100000000000000000000000000000000000000000000000000000000000000

--

ethabi decode params -t bool 0000000000000000000000000000000000000000000000000000000000000001

bool true

--

ethabi decode params -t bool -t string -t bool 00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096761766f66796f726b0000000000000000000000000000000000000000000000

bool true
string gavofyork
bool false

--

ethabi decode params -t bool[] 00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

bool[] [true,false,false]

--

ethabi decode params -t '(string,bool,string)' 00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000673706972616c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000067175617361720000000000000000000000000000000000000000000000000000```

(string,bool,string) (spiral,true,quasar)

View on Github

9 - Ethaddrgen:

Custom Ethereum vanity address generator made in Rust.

Get a shiny ethereum address and stand out from the crowd!

Disclaimer: Do not use the private key shown in this demo; it's public, strangers could steal your Eth. Never share your private key with anyone. It's your and only your responsibility to keep your private key in secret.

Features

  • Regex support (--regex/-e): Use regex pattern matching
  • Quiet mode (--quiet/-q): Output only the results
  • Stream mode (--stream/-s): Keep outputting results
  • Color settings (--color/-c): Enable/Disable colors
  • Dictionary support: If no patterns are provided as arguments, patterns are read from the standard input

Usage

Download the latest release here. To display usage, run ethaddrgen -h or ethaddrgen --help for a longer version. ethaddrgen expects the last arguments to be patterns. If no patterns are provided as arguments, ethaddrgen reads patterns from the standard input where each pattern is on a separate line.

Examples

Simple example

The following command will look for an address starting with either c0ffee, deadbeef or c0c0a. If you are on Windows, use ethaddrgen.exe instead of ethaddrgen.

ethaddrgen c0ffee deadbeef c0c0a

Regex example

The following command will look for an address starting with 10 letters. If you are on Windows, use ethaddrgen.exe instead of ethaddrgen.

ethaddrgen -e '^[abcdef]{10}'

Note that while supplying multiple regex patterns is supported, it is not recommended to use a large list of regex patterns.

Using pattern lists (dictionaries)

If no patterns are provided as arguments, patterns are read from the standard input. You can provide data to the standard input in various ways, depending on your platform:

  • Windows:
Get-Content patterns.txt | ethaddrgen.exe
  • Unix (macOS/Linux):
cat patterns.txt | ethaddrgen
# or
ethaddrgen < patterns.txt

where the patterns.txt file is a newline-separated list of patterns, for example:

c0ffee
deadbeef
c0c0a

It is not recommended to use large pattern lists with regex, as combining these features significantly decreases performance.

View on Github

10 - Ethers-rs:

Complete Ethereum & Celo library and wallet implementation in Rust.

Extensive documentation and examples are available here.

Alternatively, you may clone the repository and run cd ethers/ && cargo doc --open

You can also run any of the examples by executing: cargo run -p ethers --example <name>

Add ethers-rs to your repository

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs" }

Running the tests

Tests require the following installed:

  1. solc (>=0.8.10). We also recommend using solc-select for more flexibility.
  2. anvil
  3. geth

In addition, it is recommended that you set the ETHERSCAN_API_KEY environment variable for the abigen via Etherscan tests. You can get one here.

EVM-compatible chains support

There are many chains live which are Ethereum JSON-RPC & EVM compatible, but do not yet have support for EIP-2718 Typed Transactions. This means that transactions submitted to them by default in ethers-rs will have invalid serialization. To address that, you must use the legacy feature flag:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["legacy"] }

Polygon support

There is abigen support for Polygon and the Mumbai test network. It is recommended that you set the POLYGONSCAN_API_KEY environment variable. You can get one here.

Avalanche support

There is abigen support for Avalanche and the Fuji test network. It is recommended that you set the SNOWTRACE_API_KEY environment variable. You can get one here.

Celo Support

Celo support is turned on via the feature-flag celo:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["celo"] }

Celo's transactions differ from Ethereum transactions by including 3 new fields:

  • fee_currency: The currency fees are paid in (None for CELO, otherwise it's an Address)
  • gateway_fee_recipient: The address of the fee recipient (None for no gateway fee paid)
  • gateway_fee: Gateway fee amount (None for no gateway fee paid)

The feature flag enables these additional fields in the transaction request builders and in the transactions which are fetched over JSON-RPC.

Features

  •  Ethereum JSON-RPC Client
  •  Interacting and deploying smart contracts
  •  Type safe smart contract bindings code generation
  •  Querying past events
  •  Event monitoring as Streams
  •  ENS as a first class citizen
  •  Celo support
  •  Polygon support
  •  Avalanche support
  •  Websockets / eth_subscribe
  •  Hardware Wallet Support
  •  Parity APIs (tracing, parity_blockWithReceipts)
  •  Geth TxPool API
  •  WASM Bindings (see note)
  •  FFI Bindings (see note)
  •  CLI for common operations

Websockets

Websockets support is turned on via the feature-flag ws:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["ws"] }

Interprocess Communication (IPC)

IPC support is turned on via the feature-flag ipc:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["ipc"] }

View on Github

Thank you for following this article.

Related videos:

Build a cryptocurrency! - Blockchain in Rust 01: Blocks & Hashing

#rust #blockchain #cryptocurrencies 

Awesome  Rust

Awesome Rust

1658878980

Git Branchless: Branchless Workflow for Git Built on Rust

Branchless workflow for Git

(This suite of tools is 100% compatible with branches. If you think this is confusing, you can suggest a new name here.)

About

git-branchless is a suite of tools which enhances Git in several ways:

It makes Git easier to use, both for novices and for power users. Examples:

It adds more flexibility for power users. Examples:

  • Patch-stack workflows: strong support for "patch-stack" workflows as used by the Linux and Git projects, as well as at many large tech companies. (This is how Git was "meant" to be used.)
  • Prototyping and experimenting workflows: strong support for prototyping and experimental work via "divergent" development.
  • git sync: to rebase all local commit stacks and branches without having to check them out first.
  • git move: The ability to move subtrees rather than "sticks" while cleaning up old branches, not touching the working copy, etc.
  • Anonymous branching: reduces the overhead of branching for experimental work.
  • In-memory operations: to modify the commit graph without having to check out the commits in question.
  • git next/prev: to quickly jump between commits and branches in a commit stack.
  • git co -i/--interactive: to interactively select a commit to check out.

It provides faster operations for large repositories and monorepos, particularly at large tech companies. Examples:

  • See the blog post Lightning-fast rebases with git-move.
  • Performance tested: benchmarked on torvalds/linux (1M+ commits) and mozilla/gecko-dev (700k+ commits).
  • Operates in-memory: avoids touching the working copy by default (which can slow down git status or invalidate build artifacts).
  • Sparse indexes: uses a custom implementation of sparse indexes for fast commit and merge operations.
  • Segmented changelog DAG: for efficient queries on the commit graph, such as merge-base calculation in O(log n) instead of O(n).
  • Ahead-of-time compiled: written in an ahead-of-time compiled language with good runtime performance (Rust).
  • Multithreading: distributes work across multiple CPU cores where appropriate.
  • To my knowledge, git-branchless provides the fastest implementation of rebase among Git tools and UIs, for the above reasons.

See also the User guide and Design goals.

Demos

Repair

Undo almost anything:

  • Commits.
  • Amended commits.
  • Merges and rebases (e.g. if you resolved a conflict wrongly).
  • Checkouts.
  • Branch creations, updates, and deletions.

Why not git reflog?

git reflog is a tool to view the previous position of a single reference (like HEAD), which can be used to undo operations. But since it only tracks the position of a single reference, complicated operations like rebases can be tedious to reverse-engineer. git undo operates at a higher level of abstraction: the entire state of your repository.

git reflog also fundamentally can't be used to undo some rare operations, such as certain branch creations, updates, and deletions. See the architecture document for more details.

What doesn't git undo handle?

git undo relies on features in recent versions of Git to work properly. See the compatibility chart.

Currently, git undo can't undo the following. You can find the design document to handle some of these cases in issue #10.

  • "Uncommitting" a commit by undoing the commit and restoring its changes to the working copy.
    • In stock Git, this can be accomplished with git reset HEAD^.
    • This scenario would be better implemented with a custom git uncommit command instead. See issue #3.
  • Undoing the staging or unstaging of files. This is tracked by issue #10 above.
  • Undoing back into the middle of a conflict, such that git status shows a message like path/to/file (both modified), so that you can resolve that specific conflict differently. This is tracked by issue #10 above.

Fundamentally, git undo is not intended to handle changes to untracked files.

Comparison to other Git undo tools

  • gitjk: Requires a shell alias. Only undoes most recent command. Only handles some Git operations (e.g. doesn't handle rebases).
  • git-extras/git-undo: Only undoes commits at current HEAD.
  • git-annex undo: Only undoes the most recent change to a given file or directory.
  • thefuck: Only undoes historical shell commands. Only handles some Git operations (e.g. doesn't handle rebases).

Visualize

Visualize your commit history with the smartlog (git sl):

Why not `git log --graph`?

git log --graph only shows commits which have branches attached with them. If you prefer to work without branches, then git log --graph won't work for you.

To support users who rewrite their commit graph extensively, git sl also points out commits which have been abandoned and need to be repaired (descendants of commits marked with rewritten as abcd1234). They can be automatically fixed up with git restack, or manually handled.

Manipulate

Edit your commit graph without fear:

Why not `git rebase -i`?

Interactive rebasing with git rebase -i is fully supported, but it has a couple of shortcomings:

  • git rebase -i can only repair linear series of commits, not trees. If you modify a commit with multiple children, then you have to be sure to rebase all of the other children commits appropriately.
  • You have to commit to a plan of action before starting the rebase. For some use-cases, it can be easier to operate on individual commits at a time, rather than an entire series of commits all at once.

When you use git rebase -i with git-branchless, you will be prompted to repair your commit graph if you abandon any commits.

Installation

See https://github.com/arxanas/git-branchless/wiki/Installation.

Short version: run cargo install --locked git-branchless, then run git branchless init in your repository.

Status

git-branchless is currently in alpha. Be prepared for breaking changes, as some of the workflows and architecture may change in the future. It's believed that there are no major bugs, but it has not yet been comprehensively battle-tested. You can see the known issues in the issue tracker.

git-branchless follows semantic versioning. New 0.x.y versions, and new major versions after reaching 1.0.0, may change the on-disk format in a backward-incompatible way.

To be notified about new versions, select Watch » Custom » Releases in Github's notifications menu at the top of the page. Or use GitPunch to deliver notifications by email.

Related tools

There's a lot of promising tooling developing in this space. See Related tools for more information.

Contributing

Thanks for your interest in contributing! If you'd like, I'm happy to set up a call to help you onboard.

For code contributions, check out the Runbook to understand how to set up a development workflow, and the Coding guidelines. You may also want to read the Architecture documentation.

For contributing documentation, see the Wiki style guide.

Contributors should abide by the Code of Conduct.

Download details:
Author: arxanas
Source code: https://github.com/arxanas/git-branchless
License: GPL-2.0 license

#rust #rustlang #git

张 小龙

1589617221

Rust vs Go - Which Is More Popular?

Go and Rust are two of the hottest compiled programming languages. I develop in Go full-time and love it, and I’m learning more about Rust recently – its an exciting language. Let’s explore some differences between the two and look at which is growing faster in the popularity polls.

#Engineering #Golang #Programming #Rust #comparison #go #popular #rust