version | 5.0.1 |
license | BSD3 |
native-modules | False |
elm-version | 0.18.0 <= v < 0.19.0 |
Tag | 5.0.1 |
Committed At | 2018-05-11 06:16:57 UTC |
zwilias/elm-utf-tools | 1.0.1 <= v < 2.0.0 | 1.0.1 |
rtfeldman/hex | 1.0.0 <= v < 2.0.0 | 1.0.0 |
prozacchiwawa/elm-keccak | 1.0.1 <= v < 2.0.0 | 1.0.3 |
nathanjohnson320/base58 | 2.0.0 <= v < 3.0.0 | 2.0.2 |
hickscorp/elm-bigint | 1.0.1 <= v < 2.0.0 | 1.1.1 |
elm-lang/websocket | 1.0.2 <= v < 2.0.0 | 1.0.2 |
elm-lang/http | 1.0.0 <= v < 2.0.0 | 1.0.0 |
elm-lang/core | 5.1.1 <= v < 6.0.0 | 5.1.1 |
elm-community/string-extra | 1.4.0 <= v < 2.0.0 | 1.5.0 |
elm-community/result-extra | 2.2.0 <= v < 3.0.0 | 2.2.1 |
elm-community/maybe-extra | 4.0.0 <= v < 5.0.0 | 4.0.0 |
elm-community/list-extra | 6.1.0 <= v < 7.0.0 | 6.1.0 |
elm-community/json-extra | 2.7.0 <= v < 3.0.0 | 2.7.0 |
Warry/ascii-table | 1.0.0 <= v < 2.0.0 | 1.0.2 |
NoRedInk/elm-decode-pipeline | 3.0.0 <= v < 4.0.0 | 3.0.1 |
Chadtech/elm-bool-extra | 1.2.1 <= v < 2.0.0 | 1.2.1 |
DApps in Pure Elm
More examples and docs are in the works!
This library allows you to interact with the Ethereum blockchain much like purescript-web3
, ethers.js
, or web3.js
.
You can hook into web wallets like MetaMask and send transactions, as well as perform read-only operations off an Ethereum node.
See why elm?
Import the Eth
module and it's types.
import Eth
import Eth.Types exposing (..)
Define your endpoint
It's good to keep the node url in your model. This way it can be kept in sync with MetaMask.
Example code of this "sync" pattern to come.
type alias Model =
{ ethHttpNode : HttpProvider }
init =
{ ethHttpNode = "https://mainnet.infura.com/" }
Simple - Look at the blockchain.
getMyBalanceInHistory : Int -> Task Http.Error BigInt
getMyBalanceInHistory blockNum =
Eth.getBalanceAtBlock model.ethHttpNode myAddress (BlockNum blockNum)
Advanced - Chain tasks together.
Get all newly created contract addresses in the latest block.
In a few lines of code.
findNewestContracts : Task String (List Address)
findNewestContracts =
Eth.getBlockNumber model.ethHttpNode
|> Task.andThen (Eth.getBlock model.ethHttpNode)
|> Task.andThen
(\block ->
block.transactions
|> List.map (Eth.getTxReceipt model.ethHttpNode)
|> Task.sequence
)
|> Task.map (List.map .contractAddress >> MaybeExtra.values)
|> Task.mapError prettifyHttpError
Do not fret if the above looks perplexing. This is fairly advanced Elm. Lots is going on here.
Partial function application. Function composition. Maps within maps. Record accessor sugar.
The point is, your code can be terse, expressive, with great error handling baked in.
Btw, this is an example of Railway Oriented Programming. A great video by Scott Wlaschin.
If one were to sum up the experience of programming in Elm in two words: Fearless Refactoring
This is by no means the only pleasantry Elm has to offer.
Elm's claim to fame is zero runtime exceptions. Elm's compiler and static types are your best friends.
Both from an error catching standpoint, but just as importantly from a domain modeling perspective.
Elm's "Union types" or "ADT's" allow you to fully leverage the compiler when modeling your business domain.
See BlockId or NetworkId for instance.
Javascript Elm
---------------------------------
Npm/Yarn built-in
Webpack built-in
React built-in
Redux built-in
Typescript/Flow built-in
Immutable.JS built-in
Phenomenal tooling and resources
Time traveling debugger - Import/Export history. QA like a champ.
elm-format - Adds up to hours of tedius "work" saved.
elm-reactor - Nice dev server.
elm-test - Fuzz testing == legit.
elm-benchmark - Clone this package and give it a whirl.
Elm Package and Docs - Pleasant and consistent. Enforced semantic versioning.
Strong static types
Find errors fast with readable compiler messages.
Less millions lost from typos.
No null or undefined
Never miss a potential problem.
Purely functional
Leads to decoupled and easily refactorable code.
Great Community
Kind. Responsive. Thoughtful. Intelligent.
Pull requests and issues are greatly appreciated!
If you think there's a better way to implement parts of this library, I'd love to hear your feedback.