Last active
December 18, 2017 14:55
-
-
Save joefiorini/b844e8917fc6e9d5b8f511a43598f795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "greeting", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "greet", | |
"outputs": [ | |
{ | |
"name": "_greeting", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": false, | |
"name": "_greeting", | |
"type": "string" | |
} | |
], | |
"name": "GreetingChanged", | |
"type": "event" | |
}, | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "_greeting", | |
"type": "string" | |
} | |
], | |
"name": "setGreeting", | |
"outputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"name": "_greeting", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveGeneric #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
{-# LANGUAGE QuasiQuotes #-} | |
import Network.Ethereum.Web3 | |
import Network.Ethereum.Web3.TH | |
import System.Environment (getEnv) | |
import Control.Monad.IO.Class (liftIO) | |
import Data.Text (unpack) | |
import Data.String (fromString) | |
import Text.Printf | |
[abiFrom|data/greeting.json|] | |
getInfo :: Address -> Web3 DefaultProvider Text | |
getInfo addr = do | |
liftIO . (putStr "Name: " >>) . print =<< greet addr | |
return "" | |
-- nameStr <- name addr | |
-- return nameStr | |
main :: IO () | |
main = do | |
address <- fromString <$> getEnv "ADDRESS" | |
market <- runWeb3' (getInfo address) | |
case market of | |
Left e -> do | |
putStrLn "Unable to get info" | |
print e | |
Right name -> do | |
putStrLn "Got name:" | |
print name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment