Skip to content

Instantly share code, notes, and snippets.

@joefiorini
Last active December 18, 2017 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joefiorini/b844e8917fc6e9d5b8f511a43598f795 to your computer and use it in GitHub Desktop.
Save joefiorini/b844e8917fc6e9d5b8f511a43598f795 to your computer and use it in GitHub Desktop.
[
{
"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"
}
]
{-# 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