Getting started

Note

hs-web3 is a Haskell library. Of course you should have some knowledge about Haskell and platform tools like a cabal or stack. If you have not - Real World Haskell and Learn You a Haskell for Great Good is a good point to begin.

Installation

Simplest way is using Stackage with Nix integration.

stack install web3 --nix

Dependencies for building from source without Nix:

Quick start

Lets import library entrypoint modules using ghci:

> import Network.Ethereum.Web3
> import qualified Network.Ethereum.Api.Eth as Eth

Note

I recomend to import Network.Ethereun.Api.Eth as qualified, because it has name similar to their prefix in JSON-RPC API.

Looks anything in Eth API:

> :t Eth.blockNumber
Eth.blockNumber :: JsonRpc m => m Quantity

To run it use runWeb3 function:

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

> runWeb3 Eth.blockNumber
Right 6601059

Note

Function runWeb3 run default provider at http://localhost:8545, for using custom providers try to use runWeb3'.