Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/q9f/eth.cr

A straightforward library to build, sign, and broadcast Ethereum transactions.
https://github.com/q9f/eth.cr

crystal ethereum

Last synced: 26 days ago
JSON representation

A straightforward library to build, sign, and broadcast Ethereum transactions.

Awesome Lists containing this project

README

        

# eth.cr

[![Build Status](https://img.shields.io/github/actions/workflow/status/q9f/eth.cr/crystal.yml?branch=main)](https://github.com/q9f/eth.cr/actions)
[![Language](https://img.shields.io/github/languages/top/q9f/eth.cr?color=black)](https://github.com/q9f/eth.cr/search?l=crystal)
[![License](https://img.shields.io/github/license/q9f/eth.cr.svg?color=black)](LICENSE)

## Installation

Add the `Eth` library to your `shard.yml`.

```yaml
dependencies:
eth:
github: q9f/eth.cr
version: "~> 0.1"
```

Run `shards install`.

## Usage

```crystal
require "eth"
```

Create an Ethereum account:

```crystal
key = Key.new
# => #,
# @public_key=#,
# @y=#>,
# @address=#>

key.private_hex
# => "d6c8ace470ab0ce03125cac6abf2779c199d21a47d3e75e93c212b1ec23cfe51"

key.public_hex
# => "04bf0cf8c934bd3c57e962fdf2a47e99d6136b047f987ee2e0cb03110cafd92afc981974428f8162d3f8fce2f58d4e56341478e87d092aeb3a0edf8af97d638d04"

key.address.to_s
# => "0x2Ef1f605AF5d03874eE88773f41c1382ac71C239"
```

## Documentation

Generate a local copy with:

```shell
crystal docs
```

## Testing

The library is entirely specified through tests in `./spec`; run:

```shell
crystal spec --verbose
```

## Contribute

Create a pull request, and make sure tests and linter pass.

This pure crystal implementation is based on the ruby implementation [q9f/eth.rb](https://github.com/q9f/eth.rb) which is also used as reference to write tests against.

License: Apache License v2.0

Contributors: [**@q9f**](https://github.com/q9f/)