Web3 API for Haskell.
This release introduce changes in account system of library. Accounts is a big deal for any crypto(currency) library. Previously hs-web3
support node managed accounts only. Currently library support three types of accounts:
personal_*
API)sendRawTransaction
call)Transaction sending code have a lot of changes too. Introduced Account
typeclass in Network.Ethereum.Account
module that looks like:
class MonadTrans t => Account a t | t -> a where
-- | Run computation with given account credentials
withAccount :: JsonRpc m => a -> t m b -> m b
-- | Send transaction to contract, like a 'write' command
send :: (JsonRpc m, Method args) => args -> t m TxReceipt
-- | Call constant method of contract, like a 'read' command
call :: (JsonRpc m, Method args, AbiGet result) => args -> t m result
This is mean that sending transaction from multiple accounts simultaneously using withAccount
function is not a problem now.
... = do
withAccount () $ ...
withAccount (Personal "0x..." "password") $ ...
Transaction parametrisation was too hard previously and forced to carry a lot of vars. Currently withParam
function exported in account module use state monad for transaction parametrisation. It make code looks good and more powerful.
withAccount () $
-- Set transaction value
withParam (value .~ halfBalance) $ do
-- Send transaction to alice account
withParam (to .~ alice) $ send ()
-- Send transaction to bob account
withParam (to .~ bob) $ send ()
Finally in this release contract creation is supported via using truffle generated smart contract artifacts. Example available in tests.
Account
apiUnit
typeclass now operates over Integral
convert
function from Unit
typeclassThis is one of the biggest releases of hs-web3. The aim of this release is make library more easy to use and understand. In this release library modules are separated for three parts: ABI
operational modules, Contract
abstraction and JSON-RPC generic communication interface (Web3
module).
Imports optimization is enabled for scenario:
Network.Ethereum.Contract.TH
moduleNetwork.Ethereum.Web3
moduleFor using specified JSON-RPC method make qualified imports, like
import qualified Network.Ethereum.Web3.Eth as Eth
...
runWeb3 Eth.accounts
Bool
IntN
UIntN
Text
Bytes
BytesN
[]
ListN
ABIEncode
-> ABIPut
, ABIDecode
-> ABIGet
.Event
type class, currently TH create Data.Default
instance for Filter e
.