2018-04-25 13:45:20 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Main where
|
|
|
|
|
2018-10-04 18:12:57 +03:00
|
|
|
import Data.Default (def)
|
|
|
|
import Data.Text (unpack)
|
|
|
|
import Text.Printf (printf)
|
2018-04-25 13:45:20 +03:00
|
|
|
|
2018-11-12 12:36:43 +03:00
|
|
|
import Lens.Micro ((.~))
|
2020-05-24 07:03:56 +03:00
|
|
|
import Network.Ethereum hiding (name)
|
2018-10-04 18:12:57 +03:00
|
|
|
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
|
2018-10-04 18:12:57 +03:00
|
|
|
result <- runWeb3 $
|
|
|
|
withAccount () $
|
2018-11-12 12:36:43 +03:00
|
|
|
withParam (to .~ "0xA2f4FCb0FDe2dD59f7a1873e121bc5623e3164Eb") $ do
|
2018-10-04 18:12:57 +03:00
|
|
|
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
|
2018-11-12 12:36:43 +03:00
|
|
|
Left err -> error (show err)
|
2018-04-25 13:45:20 +03:00
|
|
|
Right info -> putStrLn info
|