Copyright | Alexander Krupenkin 2018 |
---|---|
License | BSD3 |
Maintainer | mail@akru.me |
Stability | experimental |
Portability | unportable |
Safe Haskell | None |
Language | Haskell2010 |
In Etereun there are two types of accounts: * Externally owned account (EOAs): an account controlled by a private key, and if you own the private key associated with the EOA you have the ability to send ether and messages from it. * Contract: an account that has its own code, and is controlled by code.
This module exports different kinds of EOAs: default, node managed and local. Node managed accounts
use Personal
JSON-RPC API for signing transactions. Local account sign transaction locally and
use sendRawTransaction
method to export transaction to Ethereum network.
Synopsis
- class MonadTrans t => Account a t | t -> a where
- type DefaultAccount = AccountT ()
- type PersonalAccount = AccountT Personal
- data Personal = Personal {}
- type PrivateKeyAccount = AccountT PrivateKey
- data PrivateKey = PrivateKey {
- privateKey :: !SecKey
- privateKeyChain :: !Integer
- withParam :: Account p (AccountT p) => (CallParam p -> CallParam p) -> AccountT p m a -> AccountT p m a
- to :: Lens' (CallParam p) Address
- value :: Unit value => Lens' (CallParam p) value
- gasLimit :: Lens' (CallParam p) Integer
- gasPrice :: Unit gasprice => Lens' (CallParam p) gasprice
- block :: Lens' (CallParam p) DefaultBlock
- account :: Lens' (CallParam p) p
The Account
type
class MonadTrans t => Account a t | t -> a where Source #
Account is needed for sending transactions to blockchain
Typically account is provided by node. In this case node manage accounts: encrypt and decrypt private keys, manipulate files etc. In other case web3 can derive account from private key and send to node already signed transactions.
:: JsonRpc m | |
=> a | Account params (like a password or private key) |
-> t m b | Computation that use account for sending transactions |
-> m b | Json-rpc monad |
Run computation with given account credentials
:: (JsonRpc m, Method args) | |
=> args | Contract method arguments |
-> t m TxReceipt | Receipt of sended transaction |
Send transaction to contract, like a write
command
:: (JsonRpc m, Method args, AbiGet result) | |
=> args | Contact method arguments |
-> t m result | Decoded result of method call |
Call constant method of contract, like a read
command
Instances
Default node account
type DefaultAccount = AccountT () Source #
Unlockable node account
type PersonalAccount = AccountT Personal Source #
Unlockable node managed account params
Instances
Eq Personal Source # | |
Show Personal Source # | |
Default Personal Source # | |
Defined in Network.Ethereum.Account.Personal | |
Account Personal PersonalAccount Source # | |
Defined in Network.Ethereum.Account.Personal withAccount :: JsonRpc m => Personal -> PersonalAccount m b -> m b Source # send :: (JsonRpc m, Method args) => args -> PersonalAccount m TxReceipt Source # call :: (JsonRpc m, Method args, AbiGet result) => args -> PersonalAccount m result Source # |
Local key account
type PrivateKeyAccount = AccountT PrivateKey Source #
data PrivateKey Source #
Local EOA params
PrivateKey | |
|
Instances
Eq PrivateKey Source # | |
Defined in Network.Ethereum.Account.PrivateKey (==) :: PrivateKey -> PrivateKey -> Bool # (/=) :: PrivateKey -> PrivateKey -> Bool # | |
Show PrivateKey Source # | |
Defined in Network.Ethereum.Account.PrivateKey showsPrec :: Int -> PrivateKey -> ShowS # show :: PrivateKey -> String # showList :: [PrivateKey] -> ShowS # | |
Default PrivateKey Source # | |
Defined in Network.Ethereum.Account.PrivateKey def :: PrivateKey # | |
Account PrivateKey PrivateKeyAccount Source # | |
Defined in Network.Ethereum.Account.PrivateKey withAccount :: JsonRpc m => PrivateKey -> PrivateKeyAccount m b -> m b Source # send :: (JsonRpc m, Method args) => args -> PrivateKeyAccount m TxReceipt Source # call :: (JsonRpc m, Method args, AbiGet result) => args -> PrivateKeyAccount m result Source # |
Transaction paramitrization function and lenses
withParam :: Account p (AccountT p) => (CallParam p -> CallParam p) -> AccountT p m a -> AccountT p m a Source #
withParam
is very similar to withStateT
function, it's used
to set parameters of transaction locally and revert params after out of scope.
withAccount () $ withParam (to .~ tokenAddress) $ transfer alice 42