Moac class

The Moac JSON-RPC client class. Further details of this interface and its API specification can be found at https://github.com/Moac/wiki/wiki/JSON-RPC#web3_clientversion. The API calls return null if an Moac error occurred.

Implemented by

Constructors

Moac(MoacINetworkAdapter _networkAdapter)
Moac.withConnectionParameters(MoacINetworkAdapter adapter, String hostname, String scheme, [ dynamic port = defaultHttpPort ])

Properties

host ↔ String
read / write
httpAdapter MoacINetworkAdapter
write-only
id ↔ int
Transmission id
read / write
lastError MoacError
Last error
read / write
port ↔ int
Connection parameters
read / write
printError ↔ bool
Print errors, default is off
read / write
rpcClient MoacRpcClient
Json RPC client
read / write
uri → Uri
read-only
hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

accounts() → Future<List<BigInt>>
Accounts, a list of addresses owned by client.
blockNumber() → Future<int>
Block number, the number of most recent block.
call(BigInt address, MoacDefaultBlock block, { BigInt from, int gas, int gasPrice, int value, BigInt data }) → Future<int>
Call Executes a new message call immediately without creating a transaction on the block chain. address: The address the transaction is sent to. from: (optional) The address the transaction is sent from. gas: (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. gasPrice: (optional) Integer of the gasPrice used for each paid gas value: (optional) Integer of the value send with this transaction data: (optional) Hash of the method signature and encoded parameters. For details see Moac Contract ABI block: default block parameter Returns the return value of executed contract.
clientVersion() → Future<String>
API methods / Client version
coinbaseAddress() → Future<BigInt>
The client coinbase address.
connectParameters(String scheme, String hostname, [ int port ]) → void
Connect by explicitly setting the connection parameters. Scheme must be either rpcScheme or rpcWsScheme
connectString(String hostname) → void
Connection methods / Connect using a host string of the form http://thehost.com:1234, port is optional. Scheme must be http or ws
connectUri(Uri uri) → void
Connect using a URI, port is optional
estimateGas({BigInt address, BigInt from, int gas, int gasPrice, int value, BigInt data }) → Future<int>
Estimate gas Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas. See eth_call parameters, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit. Returns the amount of gas used.
gasPrice() → Future<int>
The current price per gas in wei.
getBalance(BigInt accountNumber, MoacDefaultBlock block) → Future<int>
Get balance, the balance of the account of the given address.
getBlockByHash(BigInt blockHash, [ bool full = true ]) → Future<MoacBlock>
Get block by hash Returns information about a block by hash Hash of a block and a boolean, if true it returns the full transaction objects, if false only the hashes of the transactions, defaults to true. Returns A block object, or null when no block was found :
getBlockByNumber(MoacDefaultBlock blockNumber, [ bool full = true ]) → Future<MoacBlock>
Get block by number Returns information about a block by block number. blockNumber - defualt block parameter as in the default block parameter. A boolean, if true it returns the full transaction objects, if false only the hashes of the transactions, defaults to true. Returns See getBlockByHash
getBlockTransactionCountByHash(BigInt blockHash) → Future<int>
Block Transaction Count By Hash The number of transactions in a block from a block matching the given block hash. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.
getBlockTransactionCountByNumber(MoacDefaultBlock blockNumber) → Future<int>
Block Transaction Count By Number The number of transactions in a block matching the given block number. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.
getCode(BigInt address, MoacDefaultBlock block) → Future<int>
Get code, the code at the given address.
getFilterChanges(int filterId) → Future<MoacFilter>
Get filter changes Polling method for a filter, which returns an list of logs which occurred since last poll. Filter Id Returns an MoacFilter object or null
getFilterLogs(int filterId) → Future<MoacFilter>
Get filter logs Filter Id Returns see getFilterChanges
getLogs({MoacDefaultBlock fromBlock, MoacDefaultBlock toBlock, dynamic address, List<BigInt> topics }) → Future<MoacFilter>
Get logs The filter definition, see newFilter parameters. Returns see getFilterChanges
getStorageAt(BigInt address, int pos, MoacDefaultBlock block) → Future<BigInt>
Get Storage at, the value from a storage position at a given address. Parameters are the address of the storage, the integer position of the storage and
getTransactionByBlockHashAndIndex(BigInt blockHash, int index) → Future<MoacTransaction>
Get transaction by block hash and index. Returns information about a transaction by block hash and transaction index position. Hash of a block and integer of the transaction index position. Returns see getTransactionByHash.
getTransactionByBlockNumberAndIndex(MoacDefaultBlock blockNumber, int index) → Future<MoacTransaction>
Get transaction by block number and index. Returns information about a transaction by block number and transaction index position. A block number as in the default block parameter. Returns see getTransactionByHash.
getTransactionByHash(BigInt hash) → Future<MoacTransaction>
Get transaction by hash Returns the information about a transaction requested by transaction hash. Hash of a transaction Returns a transaction object, or null when no transaction was found:
getTransactionCount(BigInt address, MoacDefaultBlock block) → Future<int>
Transaction count, returns the number of transactions sent from an address.
getTransactionReceipt(BigInt transactionHash) → Future<MoacTransactionReceipt>
Get transaction receipt Returns the receipt of a transaction by transaction hash. Note That the receipt is not available for pending transactions. Hash of a transaction Returns a transaction receipt object, or null when no receipt was found:
getUncleByBlockHashAndIndex(BigInt blockHash, int index) → Future<MoacBlock>
Get uncle by block hash and index. Returns information about an uncle by block hash and uncle index position. Note: An uncle doesn't contain individual transactions. Hash of a block and integer of the uncle index position. Returns see getBlockByHash.
getUncleByBlockNumberAndIndex(MoacDefaultBlock blockNumber, int index) → Future<MoacBlock>
Get uncle by block number and index. Returns information about an uncle by block number and uncle index position. Note: An uncle doesn't contain individual transactions. A block number as in the default block parameter. Returns see getBlockByHash.
getUncleCountByHash(BigInt blockHash) → Future<int>
Block Uncle Count By Hash The number of uncles in a block from a block matching the given block hash. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.
getUncleCountByNumber(MoacDefaultBlock blockNumber) → Future<int>
Block Uncle Count By Number The number of uncles in a block matching the given block number. If the method returns null a count of 0 is returned, this is to distinguish between this and an error.
getWork() → Future<MoacWork>
Get work Returns the hash of the current block, the seedHash, and the boundary condition to be met ("target"). Returns an MoacWork object or null
hashrate() → Future<int>
Hashrate, returns the number of hashes per second that the node is mining with.
mining() → Future<bool>
Mining, true when mining
netListening() → Future<bool>
Net listening, true when listening
netPeerCount() → Future<int>
Net peer count,
netVersion() → Future<String>
Net version
newBlockFilter() → Future<int>
New block filter Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call getFilterChanges. Returns a filter id.
newFilter({MoacDefaultBlock fromBlock, MoacDefaultBlock toBlock, dynamic address, List<BigInt> topics }) → Future<int>
New filter Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call getFilterChanges. note on specifying topic filters: Topics are order-dependent. A transaction with a log with topics A, B will be matched by the following topic filters: [] "anything" 'A' "A in first position (and anything after)" null, B "anything in first position AND B in second position (and anything after)" A, B "A in first position AND B in second position (and anything after)" [A, B, A, B] "(A OR B) in first position AND (A OR B) in second position (and anything after)" fromBlock: - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions. toBlock: - (optional, default: "latest") Integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions. address: - (optional) Contract address or a list of addresses from which logs should originate. topics: - (optional) topics. Topics are order-dependent. Note: the user must build this structure using the utilities in the MoacUtilities class. See the Moac Wiki RPC page for examples. Returns a filter id.
newPendingTransactionFilter() → Future<int>
New pending transaction filter Creates a filter in the node, to notify when a new pending transaction arrives. To check if the state has changed, call getFilterChanges. Returns a filter id.
protocolVersion() → Future<String>
Protocol version
sendRawTransaction(BigInt signedTransaction) → Future<int>
Send raw transaction Creates new message call transaction or a contract creation for signed transactions. Takes the signed transaction data. Returns the transaction hash, or the zero hash if the transaction is not yet available.
sendTransaction(BigInt address, BigInt data, { BigInt to, int gas: 9000, int gasPrice, int value, int nonce }) → Future<int>
Send transaction Creates new message call transaction or a contract creation, if the data field contains code. address: The address the transaction is sent from. to: (optional when creating new contract) The address the transaction is directed to. gas: (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas. gasPrice: (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas value: (optional) Integer of the value send with this transaction data: The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. For details see Moac Contract ABI nonce: optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce. Returns the transaction hash, or the zero hash if the transaction is not yet available.
sha3(BigInt data) → Future<BigInt>
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
sign(BigInt account, int message) → Future<int>
Sign The sign method calculates an Moac specific signature with: sign(keccak256("\x19Moac Signed Message:\n" + len(message) + message))). Note the address to sign with must be unlocked.
submitWork(BigInt nonce, BigInt powHash, BigInt digest) → Future<bool>
Submit work Used for submitting a proof-of-work solution. The nonce found The header's pow-hash The mix digest Returns true if the provided solution is valid, otherwise false.
syncStatus() → Future<MoacSyncStatus>
Sync status, an object with data about the sync status if syncing or false if not.
uninstallFilter(int filterId) → Future<bool>
Uninstall filter Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additionally Filters timeout when they aren't requested with getFilterChanges for a period of time. Filter id Returns true if the filter was successfully uninstalled, otherwise false.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
@pragma("vm.entry-point"), inherited
toString() → String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) → bool
The equality operator. [...]
inherited

Constants

defaultHttpPort → const int
Defaults
8545
defaultWsPort → const int
8546
rpcHttpScheme → const String
Constants
'http'
rpcWsScheme → const String
'ws'