web3: Web3 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]

Client library for Third Generation of Web.


[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.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.0.0, 0.9.1.0, 1.0.0.0, 1.0.1.0
Change log CHANGELOG.md
Dependencies aeson (>=1.2.2.0 && <1.5), async (>=2.1.1.1 && <2.3), attoparsec (>=0.13.2.1 && <0.14), base (>4.10 && <4.14), base58string (>=0.10.0 && <0.11), basement (>=0.0.4 && <0.1), bytestring (>=0.10.8.1 && <0.11), cereal (>=0.5.4.0 && <0.6), cryptonite (>=0.23 && <0.27), data-default (>=0.7.1.1 && <0.8), errors (>=2.2 && <2.4), exceptions (>=0.8.3 && <0.11), generics-sop (>=0.3.1.0 && <0.6), hspec (>=2.4 && <2.8), http-client (>=0.5.7.1 && <0.7), http-client-tls (>=0.3.5.1 && <0.4), http-media (>=0.7 && <0.8.1), http-types (>=0.12 && <0.14), machines (>=0.6.3 && <0.8), memory (>=0.14.11 && <0.16), microlens (>=0.4.8.1 && <0.5), microlens-aeson (>=2.2.0.2 && <2.4), microlens-mtl (>=0.1.11.0 && <0.3), microlens-th (>=0.4.1.1 && <0.5), mtl (>=2.2.1 && <2.3), network (>=2.6 && <3.2), OneTuple (>=0.2.1 && <0.3), parsec (>=3.1.11 && <3.2), relapse (>=1.0.0.0 && <2.0), servant (>=0.13 && <0.17), servant-client (>=0.13 && <0.17), tagged (>=0.8.5 && <0.9), tar (>=0.5 && <0.6), template-haskell (>=2.12 && <2.16), text (>=1.2.2.2 && <1.3), transformers (>=0.5.2.0 && <0.6), unordered-containers (>=0.2 && <0.3), uuid-types (>=1.0.3 && <1.1), vinyl (>=0.5.3 && <0.13), websockets (>=0.11 && <0.13) [details]
License BSD-3-Clause
Copyright (c) Alexander Krupenkin 2016
Author Alexander Krupenkin
Maintainer mail@akru.me
Category Network
Home page https://github.com/airalab/hs-web3#readme
Bug tracker https://github.com/airalab/hs-web3/issues
Source repo head: git clone https://github.com/airalab/hs-web3
Uploaded by akru at 2020-05-24T05:05:41Z

Modules

[Index] [Quick Jump]

Flags

Manual Flags

NameDescriptionDefault
compiler

Enable Solidity compiler

Disabled
debug

Enable debug compiler options

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for web3-0.9.0.0

[back to package description]

Web3 API for Haskell

This library implements Haskell API client for popular Web3 platforms.

Documentation Status Build Status Hackage Matrix Hackage LTS-14 nightly Code Triagers BSD3 License

Install

stack install web3

Usage

{-# LANGUAGE OverloadedStrings #-}
module Main where

-- Basic imports
import           Network.Ethereum
import           Network.Web3

-- Eth API support
import qualified Network.Ethereum.Api.Eth   as Eth
import           Network.Ethereum.Api.Types

-- ENS support
import qualified Network.Ethereum.Ens       as Ens

-- Lens to simple param setting
import           Lens.Micro                 ((.~))

main :: IO ()
main = do
    -- Use default provider on http://localhost:8545
    ret <- runWeb3 $ do

        -- Get address of default account
        me <- head <$> Eth.accounts

        -- Get balance of default account on latest block
        myBalance <- Eth.getBalance me Latest

        -- Get half of balance
        let halfBalance = fromWei (myBalance / 2)

        -- Use default account
        withAccount () $ do
            -- Get Ethereum address via ENS
            alice <- Ens.resolve "alice.address.on.eth"
            bob   <- Ens.resolve "bob.address.on.eth"

            -- Send transaction with value
            withParam (value .~ halfBalance) $ do

                -- Send transaction to alice account
                withParam (to .~ alice) $ send ()

                -- Send transaction to bob account
                withParam (to .~ bob) $ send ()

        -- Return sended value
        return halfBalance

    -- Web3 error handling
    case ret of
        Left e  -> error $ show e
        Right v -> print (v :: Ether)  -- Print returned value in ethers

Read more in the documentation on ReadTheDocs.