-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Ethereum API for Haskell -- -- Web3 is a Haskell client library for Ethereum @package web3 @version 0.3.2.1 -- | Ethereum smart contract JSON ABI types. module Network.Ethereum.Web3.JsonAbi -- | Contract ABI is a list of method / event declarations newtype ContractABI ContractABI :: [Declaration] -> ContractABI [unABI] :: ContractABI -> [Declaration] -- | Elementrary contract interface item data Declaration -- | Contract constructor DConstructor :: [FunctionArg] -> Declaration [conInputs] :: Declaration -> [FunctionArg] -- | Method DFunction :: Text -> Bool -> [FunctionArg] -> Maybe [FunctionArg] -> Declaration [funName] :: Declaration -> Text [funConstant] :: Declaration -> Bool [funInputs] :: Declaration -> [FunctionArg] [funOutputs] :: Declaration -> Maybe [FunctionArg] -- | Event DEvent :: Text -> [EventArg] -> Bool -> Declaration [eveName] :: Declaration -> Text [eveInputs] :: Declaration -> [EventArg] [eveAnonymous] :: Declaration -> Bool -- | Fallback function DFallback :: Bool -> Declaration [falPayable] :: Declaration -> Bool -- | Method argument data FunctionArg FunctionArg :: Text -> Text -> FunctionArg -- | Argument name [funArgName] :: FunctionArg -> Text -- | Argument type [funArgType] :: FunctionArg -> Text -- | Event argument data EventArg EventArg :: Text -> Text -> Bool -> EventArg -- | Argument name [eveArgName] :: EventArg -> Text -- | Argument type [eveArgType] :: EventArg -> Text -- | Argument is indexed (e.g. placed on topics of event) [eveArgIndexed] :: EventArg -> Bool -- | Take a signature by given decl, e.g. foo(uint,string) signature :: Declaration -> Text -- | Generate method selector by given method Delcaration methodId :: Declaration -> Text -- | Generate event topic0 hash by givent event -- Delcaration eventId :: Declaration -> Text instance GHC.Classes.Ord Network.Ethereum.Web3.JsonAbi.ContractABI instance GHC.Classes.Eq Network.Ethereum.Web3.JsonAbi.ContractABI instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.JsonAbi.Declaration instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.JsonAbi.Declaration instance GHC.Show.Show Network.Ethereum.Web3.JsonAbi.ContractABI instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.JsonAbi.ContractABI instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.JsonAbi.ContractABI instance GHC.Classes.Ord Network.Ethereum.Web3.JsonAbi.Declaration instance GHC.Classes.Eq Network.Ethereum.Web3.JsonAbi.Declaration instance GHC.Show.Show Network.Ethereum.Web3.JsonAbi.Declaration instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.JsonAbi.EventArg instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.JsonAbi.EventArg instance GHC.Classes.Ord Network.Ethereum.Web3.JsonAbi.EventArg instance GHC.Classes.Eq Network.Ethereum.Web3.JsonAbi.EventArg instance GHC.Show.Show Network.Ethereum.Web3.JsonAbi.EventArg instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.JsonAbi.FunctionArg instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.JsonAbi.FunctionArg instance GHC.Classes.Ord Network.Ethereum.Web3.JsonAbi.FunctionArg instance GHC.Classes.Eq Network.Ethereum.Web3.JsonAbi.FunctionArg instance GHC.Show.Show Network.Ethereum.Web3.JsonAbi.FunctionArg -- | Ethereum address type, render and parser. module Network.Ethereum.Web3.Address -- | Ethereum account address data Address -- | Parse Address from text string fromText :: Text -> Either String Address -- | Render Address to text string toText :: Address -> Text -- | Null address zero :: Address instance GHC.Classes.Ord Network.Ethereum.Web3.Address.Address instance GHC.Classes.Eq Network.Ethereum.Web3.Address.Address instance GHC.Show.Show Network.Ethereum.Web3.Address.Address instance Data.String.IsString Network.Ethereum.Web3.Address.Address instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Address.Address instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Address.Address -- | Web3 ABI encoding data support. module Network.Ethereum.Web3.Encoding -- | Contract ABI data codec class ABIEncoding a where toData = toStrict . toLazyText . toDataBuilder fromData = maybeResult . parse fromDataParser . fromStrict toDataBuilder :: ABIEncoding a => a -> Builder fromDataParser :: ABIEncoding a => Parser a -- | Encode value into abi-encoding represenation toData :: ABIEncoding a => a -> Text -- | Parse encoded value fromData :: ABIEncoding a => Text -> Maybe a instance Network.Ethereum.Web3.Encoding.ABIEncoding GHC.Types.Bool instance Network.Ethereum.Web3.Encoding.ABIEncoding GHC.Integer.Type.Integer instance Network.Ethereum.Web3.Encoding.ABIEncoding GHC.Types.Int instance Network.Ethereum.Web3.Encoding.ABIEncoding GHC.Types.Word instance Network.Ethereum.Web3.Encoding.ABIEncoding Data.Text.Internal.Text instance Network.Ethereum.Web3.Encoding.ABIEncoding Network.Ethereum.Web3.Address.Address instance Network.Ethereum.Web3.Encoding.ABIEncoding a => Network.Ethereum.Web3.Encoding.ABIEncoding [a] -- | The type bytesM support. module Network.Ethereum.Web3.Bytes -- | Fixed length byte array newtype BytesN (n :: Nat) BytesN :: Bytes -> BytesN [unBytesN] :: BytesN -> Bytes -- | Dynamic length byte array newtype BytesD BytesD :: Bytes -> BytesD [unBytesD] :: BytesD -> Bytes instance GHC.Classes.Ord Network.Ethereum.Web3.Bytes.BytesD instance GHC.Classes.Eq Network.Ethereum.Web3.Bytes.BytesD instance GHC.Show.Show Network.Ethereum.Web3.Bytes.BytesD instance GHC.Classes.Ord (Network.Ethereum.Web3.Bytes.BytesN n) instance GHC.Classes.Eq (Network.Ethereum.Web3.Bytes.BytesN n) instance GHC.Show.Show (Network.Ethereum.Web3.Bytes.BytesN n) instance GHC.TypeLits.KnownNat n => Network.Ethereum.Web3.Encoding.ABIEncoding (Network.Ethereum.Web3.Bytes.BytesN n) instance Network.Ethereum.Web3.Encoding.ABIEncoding Network.Ethereum.Web3.Bytes.BytesD -- | Common used types and instances. module Network.Ethereum.Web3.Types -- | Any communication with Ethereum node wrapped with Web3 monad type Web3 = ReaderT Config (ExceptT Error IO) -- | Ethereum node params data Config Config :: String -> Config -- | JSON-RPC node URI [rpcUri] :: Config -> String -- | Some peace of error response data Error -- | JSON-RPC communication error JsonRpcFail :: RpcError -> Error -- | Error in parser state ParserFail :: String -> Error -- | Common head for user errors UserFail :: String -> Error -- | Run Web3 monad with default config runWeb3 :: MonadIO m => Web3 a -> m (Either Error a) -- | Run Web3 monad with given configuration runWeb3' :: MonadIO m => Config -> Web3 a -> m (Either Error a) -- | JSON-RPC error message data RpcError RpcError :: Int -> Text -> Maybe Value -> RpcError [errCode] :: RpcError -> Int [errMessage] :: RpcError -> Text [errData] :: RpcError -> Maybe Value -- | Low-level event filter data structure data Filter Filter :: Maybe Address -> Maybe [Maybe Text] -> Maybe Text -> Maybe Text -> Filter [filterAddress] :: Filter -> Maybe Address [filterTopics] :: Filter -> Maybe [Maybe Text] [filterFromBlock] :: Filter -> Maybe Text [filterToBlock] :: Filter -> Maybe Text -- | Event filder ident newtype FilterId FilterId :: Int -> FilterId -- | Changes pulled by low-level call eth_getFilterChanges data Change Change :: Text -> Text -> Text -> Text -> Text -> Address -> Text -> [Text] -> Change [changeLogIndex] :: Change -> Text [changeTransactionIndex] :: Change -> Text [changeTransactionHash] :: Change -> Text [changeBlockHash] :: Change -> Text [changeBlockNumber] :: Change -> Text [changeAddress] :: Change -> Address [changeData] :: Change -> Text [changeTopics] :: Change -> [Text] -- | The contract call params data Call Call :: Maybe Address -> Address -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Call [callFrom] :: Call -> Maybe Address [callTo] :: Call -> Address [callGas] :: Call -> Maybe Text [callPrice] :: Call -> Maybe Text [callValue] :: Call -> Maybe Text [callData] :: Call -> Maybe Text -- | The contract call mode describe used state: latest or pending data CallMode Latest :: CallMode Pending :: CallMode -- | Transaction hash text string type TxHash = Text instance GHC.Classes.Eq Network.Ethereum.Web3.Types.CallMode instance GHC.Show.Show Network.Ethereum.Web3.Types.CallMode instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.Call instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Types.Call instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.CallMode instance GHC.Show.Show Network.Ethereum.Web3.Types.Call instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.Change instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Types.Change instance GHC.Show.Show Network.Ethereum.Web3.Types.Change instance GHC.Classes.Ord Network.Ethereum.Web3.Types.FilterId instance GHC.Classes.Eq Network.Ethereum.Web3.Types.FilterId instance GHC.Show.Show Network.Ethereum.Web3.Types.FilterId instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.Filter instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Types.Filter instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Types.FilterId instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.FilterId instance GHC.Show.Show Network.Ethereum.Web3.Types.Filter instance Data.Aeson.Types.ToJSON.ToJSON Network.Ethereum.Web3.Types.RpcError instance Data.Aeson.Types.FromJSON.FromJSON Network.Ethereum.Web3.Types.RpcError instance GHC.Classes.Eq Network.Ethereum.Web3.Types.Error instance GHC.Show.Show Network.Ethereum.Web3.Types.Error instance GHC.Classes.Eq Network.Ethereum.Web3.Types.RpcError instance GHC.Show.Show Network.Ethereum.Web3.Types.RpcError instance GHC.Classes.Eq Network.Ethereum.Web3.Types.Config instance GHC.Show.Show Network.Ethereum.Web3.Types.Config instance Data.Default.Class.Default Network.Ethereum.Web3.Types.Config -- | Ethereum node JSON-RPC API methods. module Network.Ethereum.Web3.Api -- | Returns current node version string. web3_clientVersion :: Web3 Text -- | Returns Keccak-256 (not the standardized SHA3-256) of the given data. web3_sha3 :: Text -> Web3 Text -- | Returns the balance of the account of given address. eth_getBalance :: Address -> CallMode -> Web3 Text -- | Creates a filter object, based on filter options, to notify when the -- state changes (logs). To check if the state has changed, call -- getFilterChanges. eth_newFilter :: Filter -> Web3 FilterId -- | Polling method for a filter, which returns an array of logs which -- occurred since last poll. eth_getFilterChanges :: FilterId -> Web3 [Change] -- | Uninstalls a filter with given id. Should always be called when watch -- is no longer needed. eth_uninstallFilter :: FilterId -> Web3 Bool -- | Executes a new message call immediately without creating a transaction -- on the block chain. eth_call :: Call -> CallMode -> Web3 Text -- | Creates new message call transaction or a contract creation, if the -- data field contains code. eth_sendTransaction :: Call -> Web3 Text -- | Returns a list of addresses owned by client. eth_accounts :: Web3 [Address] -- | Ethereum has a metric system of denominations used as units of ether. -- Each denomination has its own unique name (some bear the family name -- of seminal figures playing a role in evolution of computer science and -- cryptoeconomics). The smallest denomination aka base unit of ether is -- called Wei. Below is a list of the named denominations and -- their value in Wei. Following a common (although somewhat -- ambiguous) pattern, ether also designates a unit (of 1e18 or one -- quintillion Wei) of the currency. Note that the currency is not -- called Ethereum as many mistakenly think, nor is Ethereum a unit. -- -- In Haskell the Ethereum unit system presented as set of types: -- Wei, Szabo, Finney, etc. They are members of -- Unit typeclass. Also available standart Show, -- Read, Num operations over Ethereum units. -- --
--   > let x = 1.2 :: Ether
--   > toWei x
--   1200000000000000000
--   
--   > let y = x + 2
--   > y
--   3.20 ether
--   
--   > let z = 15 :: Szabo
--   > y + z
--   
--   interactive:6:5: error:
--      • Couldn't match type ‘Network.Ethereum.Unit.U4’
--                      with ‘Network.Ethereum.Unit.U6’
--        Expected type: Ether
--        Actual type: Szabo
--   
module Network.Ethereum.Unit -- | Ethereum value unit class (UnitSpec a, Fractional a) => Unit a where convert = fromWei . toWei -- | Make a value from integer wei fromWei :: Unit a => Integer -> a -- | Convert a value to integer wei toWei :: Unit a => a -> Integer -- | Conversion beween two values convert :: (Unit a, Unit b) => a -> b -- | Wei unit type type Wei = Value U0 -- | KWei unit type type KWei = Value U1 -- | MWei unit type type MWei = Value U2 -- | GWei unit type type GWei = Value U3 -- | Szabo unit type type Szabo = Value U4 -- | Finney unit type type Finney = Value U5 -- | Ether unit type type Ether = Value U6 -- | KEther unit type type KEther = Value U7 instance GHC.Classes.Ord (Network.Ethereum.Unit.Value a) instance GHC.Classes.Eq (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => Network.Ethereum.Unit.Unit (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => Network.Ethereum.Unit.UnitSpec (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => GHC.Num.Num (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => GHC.Real.Fractional (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => GHC.Show.Show (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec a => GHC.Read.Read (Network.Ethereum.Unit.Value a) instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U0 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U1 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U2 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U3 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U4 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U5 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U6 instance Network.Ethereum.Unit.UnitSpec Network.Ethereum.Unit.U7 -- | Ethereum contract generalized interface, e.g. event function -- catch all event depend by given callback function type. -- --
--   runWeb3 $ event "0x..." ((MyEvent a b c) -> print (a + b * c))
--   
-- -- In other case call function used for constant calls (without -- transaction creation and change state), and sendTx function -- like a call but return no contract method return but created -- transaction hash. -- --
--   runweb3 $ do
--     x <- call "0x.." Latest MySelector
--     tx <- sendTx "0x.." nopay $ MySelector2 (x + 2)
--   
module Network.Ethereum.Web3.Contract -- | Event callback control response data EventAction -- | Continue to listen events ContinueEvent :: EventAction -- | Terminate event listener TerminateEvent :: EventAction -- | Contract method caller class ABIEncoding a => Method a where sendTx = _sendTransaction call = _call -- | Send a transaction for given contract Address, value and input -- data sendTx :: (Method a, Unit b) => Address -> b -> a -> Web3 TxHash -- | Constant call given contract Address in mode and given input -- data call :: (Method a, ABIEncoding b) => Address -> CallMode -> a -> Web3 b -- | Contract event listener class ABIEncoding a => Event a where event = _event -- | Event filter structure used by low-level subscription methods eventFilter :: Event a => a -> Address -> Filter -- | Start an event listener for given contract Address and callback event :: Event a => Address -> (a -> IO EventAction) -> Web3 ThreadId -- | Zero value is used to send transaction without money nopay :: Wei instance GHC.Classes.Eq Network.Ethereum.Web3.Contract.EventAction instance GHC.Show.Show Network.Ethereum.Web3.Contract.EventAction -- | An Ethereum node offers a RPC interface. This interface gives Ðapp’s -- access to the Ethereum blockchain and functionality that the node -- provides, such as compiling smart contract code. It uses a subset of -- the JSON-RPC 2.0 specification (no support for notifications or named -- parameters) as serialisation protocol and is available over HTTP and -- IPC (unix domain sockets on linux/OSX and named pipe’s on Windows). -- -- Web3 Haskell library currently use JSON-RPC over HTTP to access node -- functionality. module Network.Ethereum.Web3 -- | Any communication with Ethereum node wrapped with Web3 monad type Web3 = ReaderT Config (ExceptT Error IO) -- | Ethereum node params data Config Config :: String -> Config -- | JSON-RPC node URI [rpcUri] :: Config -> String -- | Some peace of error response data Error -- | JSON-RPC communication error JsonRpcFail :: RpcError -> Error -- | Error in parser state ParserFail :: String -> Error -- | Common head for user errors UserFail :: String -> Error -- | Run Web3 monad with given configuration runWeb3' :: MonadIO m => Config -> Web3 a -> m (Either Error a) -- | Run Web3 monad with default config runWeb3 :: MonadIO m => Web3 a -> m (Either Error a) -- | Event callback control response data EventAction -- | Continue to listen events ContinueEvent :: EventAction -- | Terminate event listener TerminateEvent :: EventAction -- | Contract event listener class ABIEncoding a => Event a where event = _event -- | Event filter structure used by low-level subscription methods eventFilter :: Event a => a -> Address -> Filter -- | Start an event listener for given contract Address and callback event :: Event a => Address -> (a -> IO EventAction) -> Web3 ThreadId -- | Contract method caller class ABIEncoding a => Method a where sendTx = _sendTransaction call = _call -- | Send a transaction for given contract Address, value and input -- data sendTx :: (Method a, Unit b) => Address -> b -> a -> Web3 TxHash -- | Constant call given contract Address in mode and given input -- data call :: (Method a, ABIEncoding b) => Address -> CallMode -> a -> Web3 b -- | Zero value is used to send transaction without money nopay :: Wei -- | Contract ABI data codec class ABIEncoding a where toData = toStrict . toLazyText . toDataBuilder fromData = maybeResult . parse fromDataParser . fromStrict toDataBuilder :: ABIEncoding a => a -> Builder fromDataParser :: ABIEncoding a => Parser a -- | Encode value into abi-encoding represenation toData :: ABIEncoding a => a -> Text -- | Parse encoded value fromData :: ABIEncoding a => Text -> Maybe a -- | Fixed length byte array newtype BytesN (n :: Nat) BytesN :: Bytes -> BytesN [unBytesN] :: BytesN -> Bytes -- | Dynamic length byte array newtype BytesD BytesD :: Bytes -> BytesD [unBytesD] :: BytesD -> Bytes -- | Ethereum account address data Address -- | TemplateHaskell based Ethereum contract ABI methods & event -- generator for Haskell native API. -- --
--   [abiFrom|data/sample.json|]
--   
--   main = do
--       runWeb3 $ event "0x..." $
--          (Action2 n x) -> do print n
--                               print x
--       wait
--     where wait = threadDelay 1000000 >> wait
--   
module Network.Ethereum.Web3.TH -- | QQ reader for contract ABI abi :: QuasiQuoter -- | Read contract ABI from file abiFrom :: QuasiQuoter