diff --git a/docs/web3-eth-abi.rst b/docs/web3-eth-abi.rst index 8cafdd77a69..97550145aeb 100644 --- a/docs/web3-eth-abi.rst +++ b/docs/web3-eth-abi.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -========= +============ web3.eth.abi -========= +============ The ``web3-eth-abi`` package allows you to de- and encode parameters from a ABI (Application Binary Interface). This will be used for calling functions of a deployed smart-contract. diff --git a/docs/web3-eth-admin.rst b/docs/web3-eth-admin.rst index c4a220f2ed6..f7260bc7f18 100644 --- a/docs/web3-eth-admin.rst +++ b/docs/web3-eth-admin.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -============== -web3.eth.admin -============== +================= +Web3 Admin Module +================= The ``web3-eth-admin`` package allows you to interact with the Ethereum node's admin management. @@ -19,12 +19,6 @@ The ``web3-eth-admin`` package allows you to interact with the Ethereum node's a const admin = new Admin(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); - // or using the web3 umbrella package - const web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); - - // -> web3.eth.admin - - ------------------------------------------------------------------------------ @@ -41,7 +35,7 @@ addPeer .. code-block:: javascript - web3.eth.admin.addPeer(url, [callback]) + admin.addPeer(url, [callback]) Add an admin peer on the node that Web3 is connected to with its provider. The RPC method used is ``admin_addPeer``. @@ -65,7 +59,7 @@ Example .. code-block:: javascript - web3.eth.admin.addPeer("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303") + admin.addPeer("enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303") .then(console.log); > true @@ -77,7 +71,7 @@ getDataDirectory .. code-block:: javascript - web3.eth.admin.getDataDirectory([, callback]) + admin.getDataDirectory([, callback]) Provides absolute path of the running node, which is used by the node to store all its databases. @@ -104,7 +98,7 @@ Example .. code-block:: javascript - web3.eth.admin.getDataDirectory() + admin.getDataDirectory() .then(console.log); > "/home/ubuntu/.ethereum" @@ -117,7 +111,7 @@ getNodeInfo .. code-block:: javascript - web3.eth.personal.getNodeInfo([, callback]) + admin.getNodeInfo([, callback]) This property can be queried for all the information known about the running node at the networking granularity.. @@ -155,7 +149,7 @@ Example .. code-block:: javascript - web3.eth.admin.getNodeInfo().then(console.log); + admin.getNodeInfo().then(console.log); > { enode: "enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@[::]:30303", id: "44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d", @@ -184,7 +178,7 @@ getPeers .. code-block:: javascript - web3.eth.admin.getPeers([, callback]) + admin.getPeers([, callback]) This will provide all the information known about the connected remote nodes at the networking granularity. @@ -220,7 +214,7 @@ Example .. code-block:: javascript - web3.eth.admin.getPeers().then(console.log); + admin.getPeers().then(console.log); > [{ caps: ["eth/61", "eth/62", "eth/63"], id: "08a6b39263470c78d3e4f58e3c997cd2e7af623afce64656cfc56480babcea7a9138f3d09d7b9879344c2d2e457679e3655d4b56eaff5fd4fd7f147bdb045124", @@ -261,7 +255,7 @@ setSolc .. code-block:: javascript - web3.eth.admin.setSolc(string, [, callback]) + admin.setSolc(string, [, callback]) Sets the Solidity compiler path to be used by the node when invoking the eth_compileSolidity RPC method @@ -289,7 +283,7 @@ Example .. code-block:: javascript - web3.eth.admin.setSolc("/usr/bin/solc").then(console.log); + admin.setSolc("/usr/bin/solc").then(console.log); > "solc, the solidity compiler commandline interface\nVersion: 0.3.2-0/Release-Linux/g++/Interpreter\n\npath: /usr/bin/solc" ------------------------------------------------------------------------------ @@ -300,7 +294,7 @@ startRPC .. code-block:: javascript - web3.eth.admin.startRPC(host, port, cors, apis [, callback]) + admin.startRPC(host, port, cors, apis [, callback]) It starts an HTTP based JSON RPC API webserver to handle client requests. All the parameters are optional. @@ -328,7 +322,7 @@ Example .. code-block:: javascript - web3.eth.admin.startRPC("127.0.0.1", 8545) + admin.startRPC("127.0.0.1", 8545) .then(console.log('RPC Started!')); > "RPC Started!" @@ -340,7 +334,7 @@ startWS .. code-block:: javascript - web3.eth.admin.startWS(host, port, cors, apis [, callback]) + admin.startWS(host, port, cors, apis [, callback]) It starts an WebSocket based JSON RPC API webserver to handle client requests. All the parameters are optional. @@ -368,7 +362,7 @@ Example .. code-block:: javascript - web3.eth.admin.startRPC("127.0.0.1", 8546) + admin.startRPC("127.0.0.1", 8546) .then(console.log('WS Started!')); > "WS Started!" @@ -379,7 +373,7 @@ stopRPC .. code-block:: javascript - web3.eth.admin.stopRPC([, callback]) + admin.stopRPC([, callback]) This method closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not. @@ -403,7 +397,7 @@ Example .. code-block:: javascript - web3.eth.admin.stopRPC().then(console.log); + admin.stopRPC().then(console.log); > true ------------------------------------------------------------------------------ @@ -413,7 +407,7 @@ stopWS .. code-block:: javascript - web3.eth.admin.stopWS([, callback]) + admin.stopWS([, callback]) This method closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not. @@ -437,7 +431,7 @@ Example .. code-block:: javascript - web3.eth.admin.stopWS().then(console.log); + admin.stopWS().then(console.log); > true ------------------------------------------------------------------------------ diff --git a/docs/web3-eth-ens.rst b/docs/web3-eth-ens.rst index b6aaaf2f775..374665fd25a 100644 --- a/docs/web3-eth-ens.rst +++ b/docs/web3-eth-ens.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -========= +============ web3.eth.ens -========= +============ The ``web3.eth.ens`` functions let you interacting with the Ens smart contracts. diff --git a/docs/web3-eth-iban.rst b/docs/web3-eth-iban.rst index c1c03763dc4..0276d890900 100644 --- a/docs/web3-eth-iban.rst +++ b/docs/web3-eth-iban.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -========= +============= web3.eth.Iban -========= +============= The ``web3.eth.Iban`` function lets convert Ethereum addresses from and to IBAN and BBAN. diff --git a/docs/web3-eth-miner.rst b/docs/web3-eth-miner.rst new file mode 100644 index 00000000000..2312f99fa98 --- /dev/null +++ b/docs/web3-eth-miner.rst @@ -0,0 +1,224 @@ +.. _eth-miner: + +.. include:: include_announcement.rst + +================= +Web3 Miner Module +================= + + +The ``web3-eth-miner`` package allows you to remote control the node's mining operation and set various mining specific settings. + + +.. code-block:: javascript + + import {Miner} from 'web3-eth-miner'; + + // "Web3.givenProvider" will be set if in an Ethereum supported browser. + const miner = new Miner(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); + + +------------------------------------------------------------------------------ + + +.. include:: include_package-core.rst + + + +------------------------------------------------------------------------------ + + +setExtra +======== + +.. code-block:: javascript + + miner.setExtra(extraData, [, callback]) + +This method allows miner to set extra data during mining the block. + +---------- +Parameters +---------- + +1. ``extraData`` - ``String``: Extra data which is to be set. +2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + +------- +Returns +------- + +``Promise`` - True if successful. + +------- +Example +------- + +.. code-block:: javascript + + miner.setExtra('Hello').then(console.log); + > true + +------------------------------------------------------------------------------ + + +setGasPrice +=========== + +.. code-block:: javascript + + miner.setGasPrice(gasPrice, [, callback]) + +This method allows to set minimal accepted gas price during mining transactions. Any transactions that are below this limit will get excluded from the mining process. + +---------- +Parameters +---------- + + +1. ``number | hex`` - Gas price. +2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` - True if successful. + + +------- +Example +------- + + +.. code-block:: javascript + + miner.setGasPrice("0x4a817c800").then(console.log); + > true + + miner.setGasPrice(20000000000).then(console.log); + > true + + +------------------------------------------------------------------------------ + + +setEtherBase +============ + +.. code-block:: javascript + + miner.setEtherBase(address, [, callback]) + +Sets etherbase, where mining reward will go. + +---------- +Parameters +---------- + + +1. ``String`` - address where mining reward will go. +2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` - True if successful. + + +------- +Example +------- + + +.. code-block:: javascript + + miner.setEtherBase("0x3d80b31a78c30fc628f20b2c89d7ddbf6e53cedc").then(console.log); + > true + +------------------------------------------------------------------------------ + + +start +===== + +.. code-block:: javascript + + miner.start(miningThread, [, callback]) + +Start the CPU mining process with the given number of threads. + +---------- +Parameters +---------- + + +1. ``hex | number`` - Mining threads. +2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` - True if successful. + + +------- +Example +------- + + +.. code-block:: javascript + + miner.start('0x1').then(console.log); + > true + + miner.start(1).then(console.log); + > true + +------------------------------------------------------------------------------ + + +stop +==== + +.. code-block:: javascript + + miner.stop([callback]) + +Stop the CPU mining process. + +---------- +Parameters +---------- + + +1. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. + + +------- +Returns +------- + + +``Promise`` - True if successful. + + +------- +Example +------- + + +.. code-block:: javascript + + miner.stop().then(console.log); + > true + +------------------------------------------------------------------------------ \ No newline at end of file diff --git a/docs/web3-eth-net.rst b/docs/web3-eth-net.rst index 36a98b71e78..f9e74278e01 100644 --- a/docs/web3-eth-net.rst +++ b/docs/web3-eth-net.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -========= +============ web3.eth.net -========= +============ Functions to receive details about the current connected network. diff --git a/docs/web3-eth-personal.rst b/docs/web3-eth-personal.rst index 089ee29e6fa..3b9b4136d5e 100644 --- a/docs/web3-eth-personal.rst +++ b/docs/web3-eth-personal.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -======== +================= web3.eth.personal -======== +================= The ``web3-eth-personal`` package allows you to interact with the Ethereum node's accounts. diff --git a/docs/web3-eth-subscribe.rst b/docs/web3-eth-subscribe.rst index 6d5a43e8d47..b83aa527bdd 100644 --- a/docs/web3-eth-subscribe.rst +++ b/docs/web3-eth-subscribe.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -========= +================== web3.eth.subscribe -========= +================== The ``web3.eth.subscribe`` function lets you subscribe to specific events in the blockchain. diff --git a/docs/web3-eth-txpool.rst b/docs/web3-eth-txpool.rst index 90a1806ce58..e112aaf42d3 100644 --- a/docs/web3-eth-txpool.rst +++ b/docs/web3-eth-txpool.rst @@ -18,13 +18,6 @@ The ``web3-eth-txpool`` package gives you access to several non-standard RPC met // "Web3.givenProvider" will be set if in an Ethereum supported browser. const txpool = new Txpool(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); - - // or using the web3 umbrella package - const web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); - - // -> web3.eth.txpool - - ------------------------------------------------------------------------------ @@ -41,7 +34,7 @@ content .. code-block:: javascript - web3.eth.txpool.content([callback]) + txpool.content([callback]) This API can be used to list the exact details of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. The RPC method used is ``txpool_content``. @@ -60,7 +53,7 @@ Returns - ``pending`` - ``string{}``: List of pending transactions with transaction details. - ``queued`` - ``string{}``: List of queued transactions with transaction details. - + - ``hash`` 32 Bytes - ``String``: Hash of the transaction. - ``nonce`` - ``Number``: The number of transactions made by the sender prior to this one. - ``blockHash`` 32 Bytes - ``String``: Hash of the block where this transaction was in. ``null`` when its pending. @@ -79,7 +72,7 @@ Example .. code-block:: javascript - web3.eth.txpool.content().then(console.log); + txpool.content().then(console.log); > { pending: { 0x0216d5032f356960cd3749c31ab34eeff21b3395: { @@ -155,7 +148,7 @@ inspect .. code-block:: javascript - web3.eth.txpool.inspect([, callback]) + txpool.inspect([, callback]) The property can be queried to list a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. The RPC method used is ``txpool_inspect``. @@ -185,7 +178,7 @@ Example .. code-block:: javascript - web3.eth.txpool.inspect().then(console.log); + txpool.inspect().then(console.log); > { pending: { 0x26588a9301b0428d95e6fc3a5024fce8bec12d51: { @@ -245,7 +238,7 @@ status .. code-block:: javascript - web3.eth.txpool.status([, callback]) + txpool.status([, callback]) This will provide the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. The RPC method used is ``txpool_status``. @@ -275,7 +268,7 @@ Example .. code-block:: javascript - web3.eth.txpool.status().then(console.log); + txpool.status().then(console.log); > { pending: 10, queued: 7 diff --git a/docs/web3-net.rst b/docs/web3-net.rst index 52ec34f8074..56c11788f36 100644 --- a/docs/web3-net.rst +++ b/docs/web3-net.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -======== +========== web3.*.net -======== +========== The ``web3-net`` package allows you to interact with the Ethereum nodes network properties. diff --git a/docs/web3-utils.rst b/docs/web3-utils.rst index 9076e0235e2..b6a4af8d6f8 100644 --- a/docs/web3-utils.rst +++ b/docs/web3-utils.rst @@ -2,9 +2,9 @@ .. include:: include_announcement.rst -======== +========== web3.utils -======== +========== This package provides utility functions for Ethereum dapps and other web3.js packages. diff --git a/docs/web3.rst b/docs/web3.rst index 8e170312d9f..9f275842b7f 100644 --- a/docs/web3.rst +++ b/docs/web3.rst @@ -1,9 +1,9 @@ .. include:: include_announcement.rst -===================== +==== Web3 -===================== +==== The Web3 class is a wrapper to house all Ethereum related modules.