hs-web3/examples/token/Main.hs

28 lines
873 B
Haskell
Raw Normal View History

2018-04-25 13:45:20 +03:00
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Default (def)
import Data.Text (unpack)
import Text.Printf (printf)
2018-04-25 13:45:20 +03:00
import Lens.Micro ((.~))
2020-05-24 07:03:56 +03:00
import Network.Ethereum hiding (name)
import Network.Ethereum.Account
2020-05-24 07:03:56 +03:00
import Network.Web3
2018-04-25 13:45:20 +03:00
import ERC20
main :: IO ()
main = do
result <- runWeb3 $
withAccount () $
withParam (to .~ "0xA2f4FCb0FDe2dD59f7a1873e121bc5623e3164Eb") $ do
n <- name
s <- symbol
d <- decimals
return $ printf "Token %s with symbol %s and decimals %d"
2018-04-25 13:45:20 +03:00
(unpack n) (unpack s) (fromIntegral d :: Int)
case result of
Left err -> error (show err)
2018-04-25 13:45:20 +03:00
Right info -> putStrLn info