web3: Ethereum API for Haskell

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Web3 is a Haskell client library for Ethereum


[Skip to Readme]

Properties

Versions 0.3.2.0, 0.3.2.1, 0.3.3.0, 0.3.4.0, 0.4.0.0, 0.4.1.0, 0.5.0.0, 0.5.1.0, 0.5.2.0, 0.5.2.1, 0.5.3.0, 0.5.4.0, 0.5.5.0, 0.5.5.0, 0.6.0.0, 0.7.0.0, 0.7.1.0, 0.7.2.0, 0.7.3.0, 0.8.0.0, 0.8.1.0, 0.8.2.0, 0.8.2.1, 0.8.3.0, 0.8.3.1, 0.8.3.2, 0.8.4.0, 0.9.0.0, 0.9.1.0, 1.0.0.0, 1.0.1.0
Change log None available
Dependencies aeson (>=1.1.2.0 && <1.2), attoparsec (>=0.13.1.0 && <0.14), base (>4.8 && <4.11), base16-bytestring (>=0.1.1.6 && <0.2), bytestring (>=0.10.8.1 && <0.11), cryptonite (>=0.23 && <0.24), http-client (>=0.5.7.0 && <0.6), http-client-tls (>=0.3.5.1 && <0.4), memory (>=0.14.6 && <0.15), template-haskell (>=2.11.1.0 && <2.12), text (>=1.2.2.2 && <1.3), transformers (>=0.5.2.0 && <0.6), vector (>=0.12.0.1 && <0.13) [details]
License BSD-3-Clause
Copyright Alexander Krupenkin
Author Alexander Krupenkin
Maintainer mail@akru.me
Category Network
Home page https://github.com/airalab/hs-web3#readme
Source repo head: git clone https://github.com/airalab/hs-web3
Uploaded by akru at 2017-09-18T02:51:27Z

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for web3-0.5.5.0

[back to package description]

Ethereum Haskell API

This is the Ethereum compatible Haskell API which implements the Generic JSON RPC spec.

Build Status Build status Hackage Hackage Dependencies Haskell Programming Language BSD3 License

Installation

$ git clone https://github.com/airalab/hs-web3 && cd hs-web3
$ stack setup
$ stack ghci

This library runs only paired with geth or parity Ethereum node, please start node first before using the library.

Web3 monad

Any Ethereum node communication wrapped with Web3 monadic type.

> :t web3_clientVersion
web3_clientVersion :: Provider a => Web3 a Text

To run this computation used runWeb3' or runWeb3 functions.

> runWeb3 web3_clientVersion
Right "Parity//v1.4.5-beta-a028d04-20161126/x86_64-linux-gnu/rustc1.13.0"

Function runWeb3 use default Web3 provider at localhost:8545.

> :t runWeb3
runWeb3
  :: MonadIO m => Web3 DefaultProvider b -> m (Either Web3Error b)

TemplateHaskell generator

Quasiquotation is used to parse contract ABI or load from JSON file. TemplateHaskell driven Haskell contract API generator can automatical create instances for Event and Method typeclasses and function helpers.

> :set -XQuasiQuotes
> putStr [abiFrom|data/sample.json|]
Contract:
        Events:
                Action1(address,uint256)
                Action2(string,uint256)
        Methods:
                0x03de48b3 runA1()
                0x90126c7a runA2(string,uint256)

See example of usage.

import Data.Text (unpack)
import Text.Printf

[abiFrom|data/ERC20.json|]

main :: IO ()
main = do
    Right s <- runWeb3 $ do
        n <- name token
        s <- symbol token
        d <- decimals token
        return $ printf "Token %s with symbol %s and decimals %d"
                        (unpack n) (unpack s) d
    putStrLn s
  where token = "0x237D60A8b41aFD2a335305ed458B609D7667D789"