[This is preliminary content for the Pantheon Alpha release.]
Pantheon is an open-source Ethereum client under the Apache 2.0 license and written in Java. It runs on the Ethereum public network, private networks, and test networks such as Rinkeby and Ropsten. Pantheon implements Proof of Work and Proof of Authority (Clique) consensus mechanisms.
You can use Pantheon to develop enterprise applications requiring secure, high-performance transaction processing in a private network.
Our roadmap includes Pantheon with privacy features, alternative consensus mechanisms, and other enterprise features.
Pantheon includes a command line interface and JSON-RPC API for running, maintaining, debugging, and monitoring node operations in an Ethereum network. You can use the API via RPC over HTTP or via WebSockets transport, and Pub/Sub is supported. The API supports typical Ethereum functionalities such as:
The Pantheon client supports common smart contract and Dapp development, deployment, and operational use cases, using tools such as Truffle, Remix, and web3j. The client supports common JSON-RPC API methods such as eth, net, web3, debug, and miner (note that it doesn't support Whisper or Swarm).
Get started with Pantheon:
Install and build Pantheon.
Run a Pantheon node.
Run a private network of Pantheon nodes in a Docker container.
Use the command line options to connect to public testnets or run a node for testing.
[This is preliminary content for the Pantheon Alpha release.]
Disk space and RAM: Your computer should have at least 4 GB RAM. Disk space needed varies depending on the network on which you run nodes and the sync mode you use. A small test network might require 200 MB while a mainnet node might require 1.5TB. If you use fast sync mode, allow 500 GB for the fast blockchain import snapshot. If you use full sync mode, allow 1.5 TB to 2 TB for the full blockchain archive.
IMPORTANT: Pantheon requires Java 8+ to compile; earlier versions are not supported.
Note: We recommend that you create and copy a personal access token (PAT) for your GitHub account (with all
repo
scopes enabled) in order to clone the Pantheon repo.
Clone the PegaSysEng/pantheon repo to your home directory (/home/<user>
). When Git prompts you for your username and password, enter the PAT as the password. For example:
$ git clone --recursive https://github.com/PegaSysEng/pantheon.git
Cloning into 'pantheon'...
Username: <username>
Password: <personal-access-token>
After the cloning process completes, go to the pantheon
repo directory and run git branch
to make sure you're in the branch in which you cloned the Pantheon source code (by default this is the master
branch).
Build the pantheon executable using gradlew
. You can use the -x test
option to exclude tests, which can take a long time to run and are not necessary for initial build:
./gradlew build -x test
Continue with Basic Quickstart, Docker Quickstart, or Starting Pantheon.
IMPORTANT: Pantheon requires Java 8+ to compile; earlier versions are not supported.
Log in to your GitHub account and open Settings > Developer Settings > Personal Access Token. Create and copy a personal access token (PAT) for your GitHub account in order to clone the Pantheon repo. In Scopes, select repo, and click Generate. When GitHub lists the generated token, click the clipboard icon to copy its value. Save this value, as you can only view it once.
In Git bash, go to your working directory for repositories. Clone the PegaSysEng/pantheon repo into this directory. This will create a pantheon
directory under Git revision control, and will contain the cloned PegaSysEng/pantheon repo contents.
When you invoke git clone
, Git will prompt you for your username and password. Enter the PAT instead of your password. The command and response should look like the following:
$ git clone --recursive https://github.com/PegaSysEng/pantheon
Cloning into 'pantheon'...
Username: <username>
Password: <personal-access-token>
After the cloning process completes, navigate to the pantheon
directory, which should contain the Gradle wrapper gradlew
:
cd <repos-dir>\pantheon
Build the Pantheon JAR on Windows with gradlew
:
gradlew build
Or build using assembleDist
:
./gradlew assembleDist -x test
NOTE: To run
gradlew
, you must have the JAVA_HOME system variable set to the Java installation location. For example:JAVA_HOME = C:\Program Files (x86)\Java\jdk1.8.0_181
.
Pantheon should begin to build and the output will be displayed in the console.
You can run Pantheon on a virtual machine (VM) on a cloud service such as AWS or Azure, or locally using a VM manager such as VirtualBox.
If you set up your own VM locally using a VM manager such as VirtualBox, there are a few considerations:
Make sure that Intel Virtualization Technology (VTx) and Virtualization Technology for Directed I/O (VT-d) are enabled in BIOS settings.
On Windows, you might need to disable Hyper-V in the Windows Feature list.
It is recommended that you create a VM with the following attributes:
Memory Size: Set to 4096 (recommended)
Create a virtual hard disk with at least 10 GB; 20 GB is recommended
Virtual hard disk file type: VDI (if you need to share it with other apps, use VHD)
(Optional) You can create a shared directory in order to copy block files or genesis files from the host computer to the VM. For details on how to create a shared directory, see "Share Folders" in Install Ubuntu on Oracle VirtualBox.
[This is preliminary content for the Pantheon Alpha release.]
This tutorial shows you how to install Pantheon and invoke the Pantheon CLI to run a single node in default mode:
During the tutorial, you'll import a test block file to provide the initial blocks for the node to use, then run the node. You'll then use curl
to make a call using Pantheon JSON-RPC API; this will make a request to verify that the node is running.
Install Java, Git, and Pantheon for your platform as described in Installation, then proceed through the following steps.
In this tutorial, you'll build and run Pantheon in one terminal (bash) window and run curl
commands to make JSON-RPC requests in another terminal window. To do this, either open two separate instances of Terminal
, or run a utility such as tmux to run a split screen terminal.
In the first terminal, go to the ~/pantheon
folder:
cd pantheon
Build Pantheon as described in Installation.
To run pantheon
, go to the distribution folder:
cd build/distributions/
Expand the distribution archive:
tar -xzf pantheon-0.8.0-SNAPSHOT.tar.gz
Move to the expanded folder and run pantheon
using the script to display command help:
cd pantheon-0.8.0-SNAPSHOT/
bin/pantheon --help
Import initial blocks for the node to work with from a blocks file. You can use the provided sample blocks file as shown in the following command:
bin/pantheon import ~/pantheon/testutil/src/main/resources/1000.blocks
When the import completes successfully, you should see messages containing the following:
ImportSubCommand | Runs import sub command with blocksImportPath
KeyPairUtil | Generated new key <key> and stored it to ~/pantheon/build/distributions/pantheon-0.8.0-SNAPSHOT/key
For more information on using the pantheon import
subcommand, see Pantheon CLI Syntax.
After the import successfully completes, run Pantheon with only the --rpc-enabled
option:
bin/pantheon --rpc-enabled
This runs Pantheon in default mode, meaning it runs in mainnet with the default genesis file, and peer discovery is enabled.
The --rpc-enabled
option starts the JSON-RPC service.
The terminal output will indicate that the node is synchronizing.
While the node is running, make a request on it using curl and the JSON-RPC API.
Switch to the bottom window using Ctrl+b o
and run the following curl
command:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' 127.0.0.1:8545
Note the endpoint IP and default port. You should see a result similar to the following:
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : {
"startingBlock" : "0x3e7",
"currentBlock" : "0x3e7",
"highestBlock" : "0x0"
}
}
You can now call other JSON-RPC commands listed in Pantheon JSON RPC API.
After you're finished running the demo, you can stop the Pantheon client by returning to the terminal window that runs the node and entering Ctrl+c
.
This tutorial describes how to use Pantheon to run a private network of Pantheon nodes in a Docker container.
To run this tutorial, you must have the following installed:
Linux or Mac OS
A web browser that supports Metamask (currently Chrome, Firefox, Opera, and Brave), and has the MetaMask plug-in installed. This tutorial uses screenshots from Brave.
As indicated in the installation section, clone the repository.
This tutorial uses Docker Compose to simplify assembling images and
running in a private network. To run the containers, go to the pantheon
directory and run the following shell command:
./runPantheonPrivateNetwork.sh
This script builds Pantheon, builds the images and runs the containers. It will also scale the regular node container to four containers to simulate a network with enough peers to synchronize.
When the ./runPantheonPrivateNetwork.sh
script ends, it lists the running services:
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------------
quickstart_bootnode_1 /opt/pantheon/bootnode_sta ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_explorer_1 /bin/sh -c npm start Up 0.0.0.0:32770->3000/tcp
quickstart_minernode_1 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_node_1 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_node_2 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_node_3 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_node_4 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp, 8545/tcp
quickstart_rpcnode_1 /opt/pantheon/node_start.s ... Up 30303/tcp, 30303/udp, 8084/tcp,
0.0.0.0:32769->8545/tcp, 0.0.0.0:32768->8546/tcp
And a friendly recap of the entrypoints :
****************************************************************
JSON-RPC HTTP service endpoint : http://localhost:32769 *
JSON-RPC WebSocket service endpoint : http://localhost:32768 *
Web block explorer address : http://localhost:32770 *
****************************************************************
To display this list at any time, run:
./listQuickstartServices.sh
This tutorial uses a block explorer based on the MIX project explorer.
Note: As Yarn is an Apache 2.0 licensed tool, it has been patched to fit this tutorial's needs. (You can view the patches in the quickstart/explorer folder.)
Log in to MetaMask if you don't already have it running. The block explorer displays the network to which MetaMask is connected. If you see a Peer Count of 100 in the block explorer, it's likely MetaMask is connected to mainnet or one of the testnets such as Ropsten.
To display the private network in the block explorer, you have to configure a custom RPC network.
After you sign in to MetaMask, connect to the private network RPC endpoint by:
JSON-RPC HTTP service endpoint
displayed when you started the private network.Save the configuration and return to the MetaMask main screen. Your current network is now set to the private network RPC node.
If you don't have Metamask running, the block explorer works directly without configuration. The block explorer integrates its own web3 version and knows the RPC node endpoint.
Access the explorer using the Web block explorer address
displayed when starting the private network.
You will see the already mined blocks on the right, and some stats about the RPC node we are connected to on the left.
Notice the explorer indicates 6 peers: the 4 regular nodes, the mining node and the bootnode.
Now lets play with some requests.
You can run RPC requests on rpcnode
, the node that is exposed to the host in order to listen for requests.
In this tutorial, note that the http://localhost:http-rpc-port
placeholder is http://localhost: 32769
.
Note: Make sure to replace
port
with the one provided in the./listQuickstartServices.sh
commandJSON-RPC HTTP service endpoint
. The dynamic docker port mapping changes each time you run the network.
Run the following command from the host shell :
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' http://localhost:http-rpc-port
The result should be as follows:
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "pantheon/0.8.0-SNAPSHOT"
}
Here we simply query the version of the Pantheon node, which confirms the node is running.
Now if this works, let's see some more interesting requests.
Peers are the number of other nodes connected to the RPC node.
Poll the peer count using net_peerCount
:
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' http://localhost:http-rpc-port
The result should be the following response, indicating that there are 6 peers:
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x6"
}
This provides the count of blocks already mined.
To do so, call eth_blockNumber
to retrieve the number of the most recent block:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:http-rpc-port
The result of this call should be:
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x8b8"
}
Here the hexadecimal value 0x8b8
translates to 2232
in decimal; that many blocks have already been mined.
Then call eth_getBalance
to retrieve the balance of the mining address defined in the miner node:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xfe3b557e8fb62b89f4916b721be55ceb828dbd73","latest"],"id":1}' http://localhost:http-rpc-port
The result of this call should be something like :
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x79f905c6fd34e80000"
}
0x79f905c6fd34e80000 = 2250000000000000000000 Wei (2250 Ether) (you can use a unit converter )
Wait a few seconds until new blocks are mined and make this call again. The balance should increase, meaning that the miner address successfully received the mining reward.
Also you can see this information in the block explorer. It does exactly the same thing as we did manually, connecting to the rpc node using http JSON-RPC, but displays information on a web page.
Now that you are familiar with basic RPC requests you can run JSON-RPC commands to send transactions. In order to send transactions, you will first need to create an account or use one of the 3 accounts created during the genesis of this test network.
This is the mining node codebase account:
Initial balance : 0xad78ebc5ac6200000 (200000000000000000000 in decimal)
Address: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57
Initial balance : 0x90000000000000000000000 (2785365088392105618523029504 in decimal)
Address: 0xf17f52151EbEF6C7334FAD080c5704D77216b732
Note: Pantheon does not provide an accounts management system, so if you want to create your own account, you will have to use a third party tool like Metamask.
Once you have Configured a custom RPC network, import one of the existing accounts above into metamask using the corresponding private key.
NOTE that here we don't really care about securing the keys as it's just a tutorial, but be sure to secure your accounts when you run into a real usecase. This will be discussed in a more advanced chapter.
Once this is done, try to create another account from scratch to send some ether to.
Of course remember that here we are dealing with valueless ether as we are not on the main network but on a local private network.
Send some ether from the first account (containing some ether) to the new one (that have a zero balance) and go to the explorer to check that your transaction is validated.
You should see a block in the list with one transaction, and you can look at the detail of the block and of the transactions.
This step is inspired by the PetShop tutorial on Truffle website.
Use the following instructions to run it with the quick-start Pantheon Docker network and a wallet to manage keys.
npm install -g truffle
mkdir pet-shop-tutorial
cd pet-shop-tutorial
truffle unbox pet-shop
npm install truffle-privatekey-provider
We are going to modify the truffle.js
file to add our wallet provider.
So modify the file to look like the following :
const PrivateKeyProvider = require("truffle-privatekey-provider");
const privateKey = "8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63";
const privateKeyProvider = new PrivateKeyProvider(privateKey, "[YOUR HTTP RPC NODE ENDPOINT]");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// for more about customizing your Truffle configuration!
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*" // Match any network id
},
quickstartWallet: {
provider: privateKeyProvider,
network_id: "*"
},
}
};
Then replace the [YOUR HTTP RPC NODE ENDPOINT]
placeholder with your HTTP RPC node endpoint. http://localhost:32769
in this case.
The private address indicated in the file is the miner address so we know we will have funds in it. You don't need to change it.
Once this is done, you can go through the regular tutorial steps.
When you have to run a truffle command, you only have to indicate the right network to use, as in the following command using the --network quickstartWallet
option :
truffle migrate --network quickstartWallet
Your are then able to see the transactions and contracts deployed on your local docker network if you have a look in the block explorer.
To shut down the network, you can use the script ./removePantheonPrivateNetwork.sh
; this will stop and destroy all containers.
Pantheon nodes can be used for varying purposes as described in the Overview. Nodes can connect to the Ethereum mainnet, public testnets such as Ropsten, or private networks.
When connecting to a network other than the network previously connected to, you must either delete the local block data or use the --datadir
option to specify a different data directory.
To delete the local block data, delete the database
directory in the pantheon/build/distribution/pantheon-0.8.0-SNAPSHOT
directory.
The following genesis files are provided in the /pantheon/ethereum/core/src/main/resources
directory:
dev.json
- Default genesis file when --dev-mode
specified. mainnet.json
- Default genesis file when --dev-mode
not specified. rinkeby.json
- Used to connect to Rinkeby testnet when --rinkeby
specified. ropsten.json
- Specify using --genesis
option when connecting to Ropsten testnet. To run a node on the Ethereum mainnet:
$ pantheon
To run a node on mainnet with the HTTP JSON-RPC service enabled:
$ pantheon --rpc-enabled
Replace <path>
with the path to the /pantheon
directory.
To run a node on Ropsten:
$ bin/pantheon --network-id=3 --genesis=<path>/pantheon/ethereum/core/src/main/resources/ropsten.json --bootnodes enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:3030
To run a node on Ropsten with the HTTP JSON-RPC service enabled and allow Remix to access the node:
$ bin/pantheon --rpc-enabled --rpc-cors-origins "http://remix.ethereum.org" --network-id=3 --genesis=<path>/pantheon/ethereum/core/src/main/resources/ropsten.json --bootnodes enode://6332792c4a00e3e4ee0926ed89e0d27ef985424d97b6a45bf0f23e51f0dcb5e66b875777506458aea7af6f9e4ffb69f43f3778ee73c81ed9d34c51c4b16b0b0f@52.232.243.152:30303,enode://94c15d1b9e2fe7ce56e458b9a3b672ef11894ddedd0c6f247e0f1d3487f52b66208fb4aeb8179fce6e3a749ea93ed147c37976d67af557508d199d9594c35f09@192.81.208.223:3030
Replace <path>
with the path where the Rinkeby chain data is to be saved.
To run a node on Rinkeby specifying a data directory:
$ bin/pantheon --rinkeby --datadir=<path>/rinkebyDataDir
To run a node that mines blocks at a rate suitable for testing purposes:
$ bin/pantheon --dev-mode --bootnodes= --miner-enabled --miner-coinbase fe3b557e8fb62b89f4916b721be55ceb828dbd73 --rpc-cors-origins "all" --ws-enabled --rpc-enabled
[This is preliminary content for the Pantheon Alpha release.]
Signed transactions can be sent using the eth_sendRawTransaction
JSON-RPC API method.
To avoid exposing your private keys, create signed transactions offline.
The examples all use the following libraries to create signed transactions:
Note: Other libraries (for example, webj3 or ethereumj) and tools (for example, MyEtherWallet or mycrypto.com) can also be used to create signed transactions.
Example JS scripts are provided below to create signed raw transactions to:
The example JS scripts can be used to create raw transactions to send in the private network created by the Docker Quickstart. The HTTP JSON-RPC endpoint
in the examples must be updated to the endpoint for private network.
Run a JS script to create and display the transaction string. For example:
node create_signed_raw_transaction.js
To send a signed transaction, run:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["raw_transaction_string"],"id":1}' <JSON-RPC-endpoint:port>
Where:
raw_transaction_string
is the signed raw transaction string. <JSON-RPC-endpoint:port>
is the JSON-RPC HTTP endpoint.For example:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf86a808203e882520894f17f52151ebef6c7334fad080c5704d77216b732896c6b935b8bbd400000801ca08ce4a6c12f7f273321c5dc03910744f8fb11573fcce8140aa44486d385d22fb3a051f6bcc918bf3f12e06bfccfd1451bea5c517dffee0777ebd50caf177b17f383"],"id":1}' http://localhost:8545
The following is an example of JS script that displays a signed transaction string to send ether.
const web3 = require('web3')
const ethTx = require('ethereumjs-tx')
// web3 initialization - must point to the HTTP JSON-RPC endpoint
const web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'))
// Sender address and private key
// Exclude 0x at the beginning of the private key
const addressFrom = '0x627306090abaB3A6e1400e9345bC60c78a8BEf57'
const privKey = Buffer.from('c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3', 'hex')
// Receiver address and value to transfer
const addressTo = '0xf17f52151EbEF6C7334FAD080c5704D77216b732'
const valueInEther = 2000
// Get the address transaction count - required so we use the correct nonce)
txnCount = web3.eth.getTransactionCount(addressFrom);
// Create the transaction object
var txObject = {
nonce: web3.toHex(txnCount),
gasPrice: web3.toHex(1000),
gasLimit: web3.toHex(21000),
to: addressTo,
value: web3.toHex(web3.toWei(valueInEther, 'ether'))
};
// Sign the transaction with the private key
const tx = new ethTx(txObject);
tx.sign(privKey)
//Convert to raw transaction string
const serializedTx = tx.serialize();
const rawTxHex = '0x' + serializedTx.toString('hex');
console.log("Raw transaction string=" + rawTxHex)
The following is an example of js
script that displays a signed raw transaction string to deploy a contract.
const web3 = require('web3')
const ethTx = require('ethereumjs-tx')
// web3 initialization - must point to the HTTP JSON-RPC endpoint
const web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8545'))
// Deployer address and private key
const addressFrom = '0xFE3B557E8Fb62b89F4916B721be55cEb828dBd73'
const privKey = Buffer.from('8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63', 'hex')
// Compiled contract hash - can obtain from Remix by clicking the Details button in the Compile tab.
// Compiled contract hash is value of data parameter in the WEB3DEPLOY section
const contractData = '0x608060405234801561001057600080fd5b5060dc8061001f6000396000f3006080604052600436106049576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633fa4f24514604e57806355241077146076575b600080fd5b348015605957600080fd5b50606060a0565b6040518082815260200191505060405180910390f35b348015608157600080fd5b50609e6004803603810190808035906020019092919050505060a6565b005b60005481565b80600081905550505600a165627a7a723058202bdbba2e694dba8fff33d9d0976df580f57bff0a40e25a46c398f8063b4c00360029'
// Get the address transaction count (so we use the correct nonce)
txnCount = web3.eth.getTransactionCount(addressFrom);
var txObject = {
nonce: web3.toHex(txnCount),
gasPrice: web3.toHex(1000),
gasLimit: web3.toHex(126165),
data: contractData
};
const tx = new ethTx(txObject);
tx.sign(privKey)
const serializedTx = tx.serialize();
const rawTxHex = '0x' + serializedTx.toString('hex');
console.log("Raw transaction string=" + rawTxHex);
You can interact with contracts using eth_call or eth_sendRawTransaction.
eth_call | eth_sendRawTransaction |
---|---|
Read-only | Write |
Invokes contract function locally | Broadcasts to network |
Does not change state of blockchain | Updates blockchain (for example, transfers ether between accounts) |
Does not consume gas | Requires gas |
Synchronous | Asynchronous |
Return value of contract function available immediately | Returns transaction hash only. Possible transaction may not be included in a block (for example, if the gas price is too low) |
Explains how to query block status using filters.
Explains how to set networks and configure genesis files for test and development.
Explains how to mine blocks.
How do I tell if my firewall is correctly configured to accept incoming connections? ** pantheon.log lists incoming connections. If you see "Successfully accepted connection from" in the log, connections are getting through the firewalls. Example:
2018-10-16 12:37:35.479-04:00 | nioEventLoopGroup-3-1 | INFO | NettyP2PNetwork | Successfully accepted connection from 0xa979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c
This reference describes the syntax of the Pantheon Command Line Interface (CLI) options and subcommands.
pantheon [OPTIONS] [COMMAND]
Runs the Pantheon Ethereum full node client.
--bootnodes=<enode://id@host:port>[,<enode://id@host:port>...]...
--config=<PATH>
none
. The TOML file is composed of key/value pairs. Each key is the same as the corresponding CLI option name without the leading dashes (--
). The config option is not used in the config file. Values must be treated according to TOML specifications for string, numbers, arrays and Booleans.
Example:
# Valid TOML config file
datadir="~/pantheondata" # Path
# Network
bootnodes=["enode://001@123:4567", "enode://002@123:4567", "enode://003@123:4567"]
p2p-listen="1.2.3.4:1234" # IP:port
max-peers=42
rpc-listen="5.6.7.8:5678" # IP:port
ws-listen="9.10.11.12:9101" # IP:port
# Chain
genesis="~/genesis.json" # Path to the custom genesis file
sync-mode="fast"# should be FAST or FULL (or fast or full)
# Mining
miner-enabled=true
miner-coinbase="0x0000000000000000000000000000000000000002"
--datadir=<PATH>
/build/distributions/pantheon-1.0.0-SNAPSHOT
directory in the Pantheon installation directory.--dev-mode
true
to run nodes in development mode which means you can run nodes in private or test networks. This is useful, for example, to do CPU mining more easily. In development mode, you use a custom genesis file that specifies a particular chain ID. When you set this option, you should also set the --network-id
option to the specific network you use for development. The default is false
.
--genesis=<PATH>
--max-peers=<INTEGER>
--max-trailing-peers=<INTEGER>
--miner-coinbase=<Ethereum account address>
--miner-enabled
true
when the node performs mining. The default is false
.--miner-extraData=<Extra data>
--miner-minTransactionGasPriceWei=<minTransactionGasPrice>
--network-id=<INTEGER>
1
.--no-discovery
false
.--ottoman
false
.--p2p-listen=<HOST:PORT>
--rinkeby
--rpc-enabled
true
to enable the JSON-RPC service (RPC over HTTP). The default is false
.--rpc-listen=<HOST:PORT>
--rpc-api=<api name>[,...]...
--rpc-enabled
option must be specified with this option. The default is: ETH, NET, WEB3
. The DEBUG
and MINER
APIs can also be enabled.--rpc-cors-origins=<rpcCorsAllowedOrigins>
--rpc-cors-origins "http://remix.ethereum.org"
Note: MetaMask runs as native code so does not require CORS validation. If Remix is connecting to the node through MetaMask, it also does not require CORS validation.
The default value is "none"
. If you don't whitelist any domains, you won't be able to use webapps to interact with your Pantheon node.
You can whitelist one or more domains with a comma-separated list. For example:
--rpc-cors-origins "http://foo.com, https://bar.io"
For development purposes, you can use "all"
to accept requests from any domain, but we don't recommend this for production code.
--sync-mode=<MODE>
FULL
or FAST
. The default is FULL
.--ws-enabled
true
to enable the WS-RPC (WebSockets) service. The default is false
.--ws-api=<api name>[,...]...
--ws-enabled
option must be specified with this option. The default is: ETH, NET, WEB3
. The DEBUG
and MINER
APIs can also be enabled. --ws-listen=<HOST:PORT>
-h, --help
-V, --version
The import
subcommand imports blocks from the specified file into the blockchain database:
pantheon import <block-file>
Pantheon is licensed under Apache License 2.0.
[This content is preliminary and will be published pending tech review for the Pantheon Alpha release.]
The Pantheon JSON-RPC API uses the JSON (RFC 4627) data format, which can represent objects and data fields as collections of name/value pairs, in a relatively readable, hierarchical form. Values have specific data types such as QUANTITIES (decimal integers, hexadecimal numbers, strings) and UNFORMATTED DATA (byte arrays, account addresses, hashes, and bytecode arrays).
RPC is the remote procedure call protocol (RFC 1831), which is stateless and transport agnostic in that the concepts can be used within the same process, over sockets, over HTTP, or in many various message passing environments.
In this reference, the placeholder
<JSON-RPC-http-endpoint:port>
and <JSON-RPC-ws-endpoint:port>
means an endpoint (IP address and port) of the JSON-RPC service of a Pantheon node respectively for http endpoint and for WebSocket endpoint.
To activate JSON-RPC using http or WebSocket, see --rpc-listen and --ws-listen options in the CLI documentation.
The transport attributes are:
To make RPC over HTTP requests, you can use the curl
tool, available in many systems using curl source code or pre-compiled packages.
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":53}' <JSON-RPC-http-endpoint:port>
To make requests over WebSockets, this reference uses wscat, a Node.js based command-line tool.
First connect to the WebSockets server using wscat
(you only need to connect once per session):
wscat -c ws://<JSON-RPC-ws-endpoint:port>
After the connection is established, the terminal will display a '>' prompt. Send individual requests as a JSON data package at each prompt:
{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":53}
When you make requests that might have different results depending on the block accessed, the block parameter specifies the block. Several methods, such as eth_getTransactionByBlockNumberAndIndex, have a block parameter.
The block parameter can have the following values:
blockNumber
: quantity
- Block number. Can be specified in hexadecimal or decimal. 0 represents the genesis block.earliest
: tag
- Earliest (genesis) block. latest
: tag
- Last block mined.pending
: tag
- Last block mined plus pending transactions.[Note for Alpha release: The following lists only the Pantheon JSON-RPC API commands that are currently fully or partially implemented.]
The following lists the Pantheon JSON-RPC API commands:
Returns the current client version.
None
result
: string - The current client version.
{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":53}
For an explanation of how to make an HTTP or WebSockets request using this data, see HTTP and WebSocket Requests.
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "pantheon/1.0.0-SNAPSHOT"
}
Returns a SHA3 hash of the specified data. The result value is a Keccak-256 hash, not the standardized SHA3-256.
DATA
- The data to convert to a SHA3 hash.
result
(DATA) - The SHA3 result of the input data.
curl -X POST --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x68656c6c6f20776f726c00"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x5e39a0a66544c0668bde22d61c47a8710000ece931f13b84d3b2feb44ec96d3f"
}
Returns the current network ID.
None
result
: string - The current network ID.
1
- Ethereum Mainnet2
- Morden Testnet (deprecated)3
- Ropsten Testnet4
- Rinkeby Testnet42
- Kovan Testnetcurl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":53}' <JSON-RPC-endpoint:port>
Mainnet:
{
"jsonrpc" : "2.0",
"id" : 51,
"result" : "1"
}
Ropsten:
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "3"
}
Indicates whether the client is actively listening for network connections.
None
result
(BOOLEAN) - true
if the client is actively listening for network connections; otherwise false.
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : true
}
Returns the number of peers currently connected to the client.
None
result
: integer - The number of connected peers in hexadecimal.
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x5"
}
Returns an object with data about the sync status, or FALSE if not syncing.
None
result
: Object|Boolean - An object with sync status data or FALSE, when not syncing:
startingBlock
: QUANTITY - The block at which the import started (will only be reset, after the sync reached his head).currentBlock
: QUANTITY - The current block, same as eth_blockNumber.highestBlock
: QUANTITY - The estimated highest block.curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":51}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 51,
"result" : {
"startingBlock" : "0x1d4bff",
"currentBlock" : "0x1d4bff",
"highestBlock" : "0x0"
}
Returns the client coinbase address.
To set a coinbase address, call the pantheon CLI with the --miner-coinbase
option set to a valid Ethereum account address. You can get the Ethereum account address from a client such as MetaMask or Etherscan. For example:
bin/pantheon --genesis=/home/donn/pantheon/ethereum/core/src/main/resources/ropsten.json --miner-coinbase="0xDD37f65dB31c107F773E82a4F85C693058fEf7a9" --dev-mode=true --rpc-enabled
None
result
(DATA, 20 bytes) - The current coinbase address.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0xdd37f65db31c107f773e82a4f85c693058fef7a9"
}
If you have not specified a coinbase, you will receive this message:
{
"jsonrpc" : "2.0",
"id" : 53,
"error" : {
"code" : -32000,
"message" : "Coinbase must be explicitly specified"
}
}
Indicates whether the client is actively mining new blocks.
None
result
(BOOLEAN) - true
if the client is actively mining new blocks; otherwise false
.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : true
}
Returns the current gas unit price in wei.
None
result
(QUANTITY) - Integer value representing the current gas unit price in wei.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x3e8"
}
Returns a list of account addresses that the client owns.
NOTE: This method returns an empty object; this is the correct behavior, not a malfunction, and simply reflects the current state of mainnet.
None
Array of DATA
: A list of 20-byte account addresses that the client owns.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : [ ]
}
Returns the index of the current block the client is processing.
None
result
: QUANTITY - Hexadecimal integer representing the 0-based index of the block that the client is currently processing.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":51}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 51,
"result" : "0x2377"
}
Returns the account balance of the specified address.
DATA
- 20-byte account address from which to retrieve the balance.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: QUANTITY - Integer value of the current balance in wei.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xdd37f65db31c107f773e82a4f85c693058fef7a9", "latest"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x0"
}
Returns the value of a storage position at a specified address.
DATA
- A 20-byte storage address.
QUANTITY
- Integer index of the storage position.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: DATA - The value at the specified storage position.
Calculating the correct position depends on the storage you want to retrieve.
curl -X POST --data '{"jsonrpc":"2.0","method": "eth_getStorageAt","params": ["0x3B3F3E","0x0","latest"],"id": 53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x0000000000000000000000000000000000000000000000000000000000000000"
}
Returns the number of transactions sent from a specified address.
DATA
- A 20-byte account address.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: QUANTITY - Integer representing the number of transactions sent from the specified address.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f","latest"],"id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x1"
}
Returns the number of transactions in the block matching the given block hash.
DATA
- A 32-byte block hash.
result
: QUANTITY - Integer representing the number of transactions in the specified block.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : null
}
Returns the number of transactions in a block matching the specified block number.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: QUANTITY - Integer representing the number of transactions in the specified block.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0xe8"],"id":51}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 51,
"result" : "0x8"
}
Returns the number of uncles in a block from a block matching the given block hash.
DATA
- A 32-byte block hash.
result
: QUANTITY - Integer representing the number of uncles in the specified block.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : null
}
Returns the number of uncles in a block matching the specified block number.
QUANTITY|TAG
- Integer representing either the 0-based index of the block within the blockchain, or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: QUANTITY - Integer representing the number of uncles in the specified block.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockNumber","params":["0xe8"],"id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : "0x1"
}
Returns the code of the smart contract at the specified address. Compiled smart contract code is stored as a hexadecimal value.
DATA
- 20-byte contract address.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
: DATA - Code stored at the specified address.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xa50a51c09a5c451c52bb714527e1974b686d8e77", "latest"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc": "2.0",
"id": 53,
"result": "0x60806040526004361060485763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416633fa4f2458114604d57806355241077146071575b600080fd5b348015605857600080fd5b50605f6088565b60408051918252519081900360200190f35b348015607c57600080fd5b506086600435608e565b005b60005481565b60008190556040805182815290517f199cd93e851e4c78c437891155e2112093f8f15394aa89dab09e38d6ca0727879181900360200190a1505600a165627a7a723058209d8929142720a69bde2ab3bfa2da6217674b984899b62753979743c0470a2ea70029"
}
Sends a signed transaction. A transaction can send ether, deploy a contract, or interact with a contract.
You can interact with contracts using eth_sendRawTransaction or eth_call.
To avoid exposing your private key, create signed transactions offline and send the signed transaction data using this method. For information on creating signed transactions and using eth_sendRawTransaction
, refer to Using Pantheon.
Note: Pantheon does not implement eth_sendTransaction because this relies on private key management by the client that could potentially be exposed during the transaction.
DATA
- Hash of the signed raw transaction in hexadecimal format; for example:
params: ["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"]
result
: DATA
- 32-byte transaction hash, or zero hash if the transaction is not yet available.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"],"id":1}' <JSON-RPC-endpoint:port>
{
"id":1,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
Invokes a contract function locally and does not change the state of the blockchain.
You can interact with contracts using eth_sendRawTransaction or eth_call.
OBJECT - Transaction call object.
QUANTITY|TAG - Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
(DATA) - Return value of the executed contract.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0xdd37f65db31c107f773e82a4f85c693058fef7a9","to":"0x69498dd54bd25aa0c886cf1f8b8ae0856d55ff13","value":"0.1"}],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"error" : {
"code" : -32602,
"message" : "Invalid params"
}
}
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. (Per Etherscan: gas price * gas used.) The transaction is added to the blockchain. The estimate may be significantly more than the amount of gas actually used by the transaction for reasons including EVM mechanics and node performance.
NOTE: Parameters are the same as the eth_call parameters, except that all properties are optional. If you do not specify a
gas
limit, Pantheon uses the gas limit from the pending block as an upper bound. As a result, the returned estimate might not be enough to execute the call or transaction when the amount of gas is higher than the pending block's gas limit.
OBJECT - Transaction call object.
QUANTITY|TAG - Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
result
(QUANTITY) - The amount of gas used.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x687422eea2cb73b5d3e242ba5456b782919afc85","to":"0xdd37f65db31c107f773e82a4f85c693058fef7a9","value":"0x1"}],"id":53}' <JSON-RPC-endpoint:port>
The following result yields a gas amount estimate of 21000 wei (0x5208) for the transaction.
{
"jsonrpc" : "2.0",
"id" : 54,
"result" : "0x5208"
}
Returns information about the block by hash.
DATA
- 32-byte hash of a block.
Boolean
- If true
, returns the full transaction objects; if false
, returns the transaction hashes.
result
: OBJECT - Block object , or null
when no block is found.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0x16b69965a5949262642cfb5e86368ddbbe57ab9f17d999174a65fd0e66580d8f", false],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : {
"number" : "0x7",
"hash" : "0x16b69965a5949262642cfb5e86368ddbbe57ab9f17d999174a65fd0e66580d8f",
"parentHash" : "0xe9bd4b277983580ef0eabad6011891f8b6aff9381a78bd1c4faca374a48b3e09",
"nonce" : "0x46acb59e85b5bb6d",
"sha3Uncles" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot" : "0x7aa0913c235f272eb6ed6ab74ba5a057e0a62c1c1d1dbccfd971221e6b6e83a3",
"stateRoot" : "0xfaf6520d6e3d24107a4309855593341ab87a1744dbb6eea4e709b92e9c9107ca",
"receiptsRoot" : "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
"miner" : "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"difficulty" : "0x5",
"totalDifficulty" : "0x10023",
"extraData" : "0x",
"size" : "0x270",
"gasLimit" : "0x1000000",
"gasUsed" : "0x5208",
"timestamp" : "0x5bbbe99f",
"uncles" : [ ],
"transactions" : [ "0x2cc6c94c21685b7e0f8ddabf277a5ccf98db157c62619cde8baea696a74ed18e" ]
}
}
Returns information about a block by block number.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
Boolean
- If true
, returns the full transaction objects; if false
, returns only the hashes of the transactions.
result
: OBJECT - Block object , or null
when no block is found.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x64", true],"id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : {
"number" : "0x64",
"hash" : "0xdfe2e70d6c116a541101cecbb256d7402d62125f6ddc9b607d49edc989825c64",
"parentHash" : "0xdb10afd3efa45327eb284c83cc925bd9bd7966aea53067c1eebe0724d124ec1e",
"nonce" : "0x37129c7f29a9364b",
"sha3Uncles" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom" : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"stateRoot" : "0x90c25f6d7fddeb31a6cc5668a6bba77adbadec705eb7aa5a51265c2d1e3bb7ac",
"receiptsRoot" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"miner" : "0xbb7b8287f3f0a933474a79eae42cbca977791171",
"difficulty" : "0x42be722b6",
"totalDifficulty" : "0x19b5afdc486",
"extraData" : "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32",
"size" : "0x21e",
"gasLimit" : "0x1388",
"gasUsed" : "0x0",
"timestamp" : "0x55ba43eb",
"uncles" : [ ],
"transactions" : [ ]
}
}
Returns transaction information for the specified transaction hash.
DATA
- 32-byte transaction hash.
Object - Transaction object, or null
when no transaction is found.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : {
"blockHash" : "0x510efccf44a192e6e34bcb439a1947e24b86244280762cbb006858c237093fda",
"blockNumber" : "0x422",
"from" : "0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"gas" : "0x5208",
"gasPrice" : "0x3b9aca00",
"hash" : "0xa52be92809541220ee0aaaede6047d9a6c5d0cd96a517c854d944ee70a0ebb44",
"input" : "0x",
"nonce" : "0x1",
"to" : "0x627306090abab3a6e1400e9345bc60c78a8bef57",
"transactionIndex" : "0x0",
"value" : "0x4e1003b28d9280000",
"v" : "0xfe7",
"r" : "0x84caf09aefbd5e539295acc67217563438a4efb224879b6855f56857fa2037d3",
"s" : "0x5e863be3829812c81439f0ae9d8ecb832b531d651fb234c848d1bf45e62be8b9"
}
}
Returns transaction information for the specified block hash and transaction index position.
DATA
- 32-byte hash of a block.
QUANTITY
- Integer representing the transaction index position.
Object - Transaction object, or null
when no transaction is found.
This request returns the 3rd transaction in the 82990 block on the Ropsten testnet. You can also view this block and transaction on Etherscan.
Note: You must be synchronized to at least the block containing the transaction for the request to return it.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7", "0x2"], "id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : {
"blockHash" : "0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7",
"blockNumber" : "0x1442e",
"from" : "0x70c9217d814985faef62b124420f8dfbddd96433",
"gas" : "0x3d090",
"gasPrice" : "0x57148a6be",
"hash" : "0xfc766a71c406950d4a4955a340a092626c35083c64c7be907060368a5e6811d6",
"input" : "0x51a34eb8000000000000000000000000000000000000000000000029b9e659e41b780000",
"nonce" : "0x2cb2",
"to" : "0xcfdc98ec7f01dab1b67b36373524ce0208dc3953",
"transactionIndex" : "0x2",
"value" : "0x0",
"v" : "0x2a",
"r" : "0xa2d2b1021e1428740a7c67af3c05fe3160481889b25b921108ac0ac2c3d5d40a",
"s" : "0x63186d2aaefe188748bfb4b46fb9493cbc2b53cf36169e8501a5bc0ed941b484"
}
}
Returns transaction information for the specified block number and transaction index position.
QUANTITY|TAG
- Integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in Block Parameter.
QUANTITY
- The transaction index position.
Object - Transaction object, or null
when no transaction is found.
This request returns the 3rd transaction in the 82990 block on the Ropsten testnet. You can also view this block and transaction on Etherscan.
Note: You must be synchronized to at least the block containing the transaction for the request to return it.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["82990", "0x2"], "id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : {
"blockHash" : "0xbf137c3a7a1ebdfac21252765e5d7f40d115c2757e4a4abee929be88c624fdb7",
"blockNumber" : "0x1442e",
"from" : "0x70c9217d814985faef62b124420f8dfbddd96433",
"gas" : "0x3d090",
"gasPrice" : "0x57148a6be",
"hash" : "0xfc766a71c406950d4a4955a340a092626c35083c64c7be907060368a5e6811d6",
"input" : "0x51a34eb8000000000000000000000000000000000000000000000029b9e659e41b780000",
"nonce" : "0x2cb2",
"to" : "0xcfdc98ec7f01dab1b67b36373524ce0208dc3953",
"transactionIndex" : "0x2",
"value" : "0x0",
"v" : "0x2a",
"r" : "0xa2d2b1021e1428740a7c67af3c05fe3160481889b25b921108ac0ac2c3d5d40a",
"s" : "0x63186d2aaefe188748bfb4b46fb9493cbc2b53cf36169e8501a5bc0ed941b484"
}
}
Returns the receipt of a transaction by transaction hash. Receipts for pending transactions are not available.
DATA
- 32-byte hash of a transaction.
Object
- Transaction receipt object, or null
when no receipt is found.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x504ce587a65bdbdb6414a0c6c16d86a04dd79bfcc4f2950eec9634b30ce5370f"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"blockHash": "0xe7212a92cfb9b06addc80dec2a0dfae9ea94fd344efeb157c41e12994fcad60a",
"blockNumber": "0x50",
"contractAddress": null,
"cumulativeGasUsed": "0x5208",
"from": "0x627306090abab3a6e1400e9345bc60c78a8bef57",
"gasUsed": "0x5208",
"logs": [],
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x1",
"to": "0xf17f52151ebef6c7334fad080c5704d77216b732",
"transactionHash": "0xc00e97af59c6f88de163306935f7682af1a34c67245e414537d02e422815efc3",
"transactionIndex": "0x0"
}
}
Creates a topic filter with the specified options to notify (log) when the state changes. To determine whether the state has changed, call eth_getFilterChanges.
Object
- Filter options object.
Note: Topics are order-dependent. A transaction with a log containing topics [A, B]
would be matched with the following topic filters:
For example, params could be specified as follows:
params: [{ "fromBlock": "earliest", "toBlock": "0x4", "address": "0xc94770007dda54cF92009BFF0dE90c06F603a09f", "topics": ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", null, ["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc"]] }]
result
: QUANTITY - The filter ID.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":[]}],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x3"
}
Invalid params error:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"fromBlock": "earliest","toBlock": "latest","address": "0xDD37f65dB31c107F773E82a4F85C693058fEf7a9","topics": []}],"id":53}' 127.0.0.1:8545 { "jsonrpc" : "2.0", "id" : 53, "error" : { "code" : -32602, "message" : "Invalid params" } }
Creates a filter in the node that notifies when a new block arrives. To determine whether the state has changed, call eth_getFilterChanges.
None
QUANTITY
- A hexadecimal integer filter ID. Each time you call this method, it creates a new filter, and the index is incremented by 1.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":53}' <JSON-RPC-endpoint:port>
Assuming you have previously called eth_newBlockFilter
two times, it will assign a filter ID of 3:
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x3"
}
Creates a filter in the node that notifies when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
None
QUANTITY
- A hexadecimal integer filter ID. Each time you call this method, it creates a new filter, and the index is incremented by 1.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":53}' <JSON-RPC-endpoint:port>
Assuming you have previously called eth_newBlockFilter
three times, it will assign a filter ID of 4:
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : "0x4"
}
Uninstalls a filter with the specified ID. This method should always be called when notification is no longer needed. Note that filters time out when they are not requested with eth_getFilterChanges for a period of time.
This method deletes filters of any type: block filters, pending transaction filters, and state (topic) filters.
QUANTITY
- A hexadecimal integer filter ID specifying the filter to be deleted.
Boolean
- true
if the filter was successfully uninstalled; otherwise false
.
The following request deletes the block filter with an ID of 0x4:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0x4"],"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : true
}
Polls the specified filter and returns an array of logs that have occurred since the last poll.
QUANTITY
- A hexadecimal integer filter ID.
result
: Array of Object
- List of logs, or an empty array if nothing has changed since the last poll.
For filters created with eth_newBlockFilter
, returns 32-byte DATA block hashes; for example ["0x3454645634534..."]
.
For filters created with eth_newPendingTransactionFilter
, returns transaction hashes (32-byte DATA); for example ["0x6345343454645..."]
.
For filters created with eth_newFilter
, returns log objects.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0xa"]:"id":53}' <JSON-RPC-endpoint:port>
The following response indicates that nothing has changed since the last poll:
{
"jsonrpc" : "2.0",
"id" : 53,
"result" : [ ]
}
Returns an array of logs matching the filter with the specified ID.
QUANTITY
- An integer representing the filter ID.
Same as eth_getFilterChanges.
The following example requests logs for filter ID 0x16 (22 decimal):
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x3"]"id":53}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : [ {
"logIndex" : "0x0",
"removed" : false,
"blockNumber" : "0x14427",
"blockHash" : "0x677bf4b962464e6dfd548d6a30b6c703dd78c7cc3602825a7013a6e90a001d2a",
"transactionHash" : "0x7bf9876a9de3c0add38495e21a17b96c81b3f18e0990a4a3aecdf9f47fea0eed",
"transactionIndex" : "0x0",
"address" : "0xe8fe77d1576d0972d453b49bfaa84d716173d133",
"data" : "0x0000000000000000000000001046c9bdec0e634fbd7cf91afebd93cc854432b10000000000000000000000002101416eeaf73acb66d124f79efde9631662a83a0000000000000000000000006f72045702a34c473da863945221965c61528bd3",
"topics" : [ "0xc36800ebd6079fdafc3a7100d0d1172815751804a6d1b7eb365b85f6c9c80e61", "0x000000000000000000000000b344324aa2a82a6fda8459e40923e1fd65bfac36" ]
} ]
}
Returns an array of all logs matching a specified filter object.
Object
- Filter options object
Same as eth_getFilterChanges.
The request above returns the logs for the 82893 block on the Ropsten testnet. You can also view this block on Etherscan.
Note: You must be synchronised to at least the requested block for the request to return the logs.
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"blockhash":"0x677bf4b962464e6dfd548d6a30b6c703dd78c7cc3602825a7013a6e90a001d2a"}], "id":1}' <JSON-RPC-endpoint:port>
{
"jsonrpc" : "2.0",
"id" : 1,
"result" : [ {
"logIndex" : "0x0",
"removed" : false,
"blockNumber" : "0x14427",
"blockHash" : "0x677bf4b962464e6dfd548d6a30b6c703dd78c7cc3602825a7013a6e90a001d2a",
"transactionHash" : "0x7bf9876a9de3c0add38495e21a17b96c81b3f18e0990a4a3aecdf9f47fea0eed",
"transactionIndex" : "0x0",
"address" : "0xe8fe77d1576d0972d453b49bfaa84d716173d133",
"data" : "0x0000000000000000000000001046c9bdec0e634fbd7cf91afebd93cc854432b10000000000000000000000002101416eeaf73acb66d124f79efde9631662a83a0000000000000000000000006f72045702a34c473da863945221965c61528bd3",
"topics" : [ "0xc36800ebd6079fdafc3a7100d0d1172815751804a6d1b7eb365b85f6c9c80e61", "0x000000000000000000000000b344324aa2a82a6fda8459e40923e1fd65bfac36" ]
} ]
}
Returns the hash of the current block, the seed hash, and the target boundary condition to be met.
None
result
: Array of DATA
with the following fields:
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getWork","params":[],"id":1}' <JSON-RPC-endpoint:port>
{
"id":1,
"jsonrpc":"2.0",
"result": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0x5EED00000000000000000000000000005EED0000000000000000000000000000",
"0xd1ff1c01710000000000000000000000d1ff1c01710000000000000000000000"
]
}
Attempts to run the transaction as it was executed on the network. It will replay transactions that might already have been executed before it attempts to execute the transaction that corresponds to the specified hash.
You can use this method with tools such as Remix when you want to execute a transaction step-by-step.
transactionHash
: data
- The transaction hash.
options
: string
- (Optional) Specifies request options as follows:
disableStorage
: BOOL
- true
disables storage capture. The default is false
.disableMemory
: BOOL
- true
disables memory capture. The default is false
.disableStack
: BOOL
- true
disables stack capture. The default is false
.tracer
: STRING
- A tracer object that enables JavaScript-based transaction tracing. If you specify a tracer object, the previous four arguments are ignored. A tracer object has two methods, step
and result
:step
is a function that takes two arguments, log
and db
. This function is called for each step of the EVM, or when an error occurs, as the specified transaction is traced.log
has the following fields:pc
: number
- The current program counter.op
: object
- An OpCode
object representing the current opcode.gas
: number
- The amount of gas remaining.gasPrice
: number
- The cost in wei of each unit of gas.memory
: object
- A structure representing the contract's memory space.stack
: array[big.Int]
- The EVM execution stack.depth
: number
- The execution depth.account
: data
- The address of the account executing the current operation.err
: If an error occured, this field contains information about the error. If err
is non-null, you can ignore all other fields.timeout
: STRING
- A duration string that overrides the default timeout of 5 seconds for JavaScript-based tracing calls. A duration string is a signed sequence of decimal numbers, each with an optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".A tracer
object, as described above.
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params”:[“0xaaaaaaaaaaaaaaaaaaa”,{“disableStorage":true}],"id”:1}' <JSON-RPC-endpoint:port>
{...}
Starts the CPU mining process on the client.
None
result
: boolean | integer
- true
if the mining start request was received successfully; otherwise returns an error. An example of an error condition would be when a coinbase has not been specified.
curl -X POST --data '{"jsonrpc":"2.0","method":"miner_start","params":[],"id":1}' <JSON-RPC-endpoint:port>
{...}
Stops the CPU mining process on the client.
None
result
: boolean | integer
- true
if the mining stop request was received successfully; otherwise returns an error. An example of an error condition would be when a coinbase has not been specified.
curl -X POST --data '{"jsonrpc":"2.0","method":"miner_stop","params":[],"id":1}' <JSON-RPC-endpoint:port>
{...}
The following objects are parameters for or returned by JSON-RPC Methods:
Returned by eth_getBlockByHash and eth_getBlockByNumber.
Key | Type | Value |
---|---|---|
number |
Quantity, Integer | Block number. null when block is pending. |
hash |
Data, 32 bytes | Hash of the block. null when block is pending. |
parentHash |
Data, 32 bytes | Hash of the parent block. |
nonce |
Data, 8 bytes | Hash of the generated proof of work. null when block is pending. |
sha3Uncles |
Data, 32 bytes | SHA3 of the uncle's data in the block. |
logsBloom |
Data, 256 bytes | Bloom filter for the block logs. null when block is pending. |
transactionsRoot |
Data, 32 bytes | Root of the transaction trie for the block. |
stateRoot |
Data, 32 bytes | Root of the final state trie for the block. |
receiptsRoot |
Data, 32 bytes | Root of the receipts trie for the block. |
miner |
Data, 20 bytes | Address to which mining rewards were paid. |
difficulty |
Quantity, Integer | Difficulty for this block. |
totalDifficulty |
Quantity, Integer | Total difficulty of the chain until this block. |
extraData |
Data | Extra data field of this block. |
size |
Quantity, Integer | Size of block in bytes. |
gasLimit |
Quantity | Maximum gas allowed in this block. |
gasUsed |
Quantity | Total gas used by all transactions in this block. |
timestamp |
Quantity | Unix timestamp when block was collated. |
transactions |
Array | Array of transaction objects, or 32 byte transaction hashes depending on the specified boolean parameter. |
uncles |
Array | Array of uncle hashes. |
Parameter for eth_newFilter and eth_getLogs.
Key | Type | Required/Optional | Value |
---|---|---|---|
fromBlock |
Quantity |Tag | Optional | Integer block number or latest , pending , earliest . See Block Parameter. Default is latest . |
toBlock |
Quantity |Tag | Optional | Integer block number or latest , pending , earliest . See Block Parameter. Default is latest . |
address |
Data | Array | Optional | Contract address or array of addresses from which logs originate. |
topics |
Array of Data, 32 bytes each | Optional | Array of 32-byte topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options. |
eth_getLogs has an additional key.
Key | Type | Required/Optional | Value |
---|---|---|---|
blockhash |
Data, 32 bytes | Optional | Hash of block for which to return logs. If blockhash is specified, fromBlock and toBlock cannot be specified. |
Returned by eth_getFilterChanges and transaction receipt objects can contain an array of log objects.
Key | Type | Value |
---|---|---|
removed |
Tag | true when log removed due to chain reorganization. false if valid log. |
logIndex |
Quantity, Integer | Log index position in the block. null when log is pending. |
transactionIndex |
Quantity, Integer | Index position of transaction from which log was created. null when log is pending. |
transactionHash |
Data, 32 bytes | Hash of transaction from which log was created. null when log is pending. |
blockHash |
Data, 32 bytes | Hash of block in which log included. null when log is pending. |
blockNumber |
Quantity | Number of block in which log included. null when log is pending. |
address |
Data, 20 bytes | Address from which log originated. |
data |
Data | Non-indexed arguments of log. |
topics |
Array of Data, 32 bytes each | 0 to 4 indexed log arguments. In Solidity, the first topic is the hash of the signature of the event (for example, Deposit(address, bytes32, unit256) ) except you declare the event with an anonymous specifier.) |
Returned by eth_getTransactionByHash, eth_getTransactionByBlockHashAndIndex, and eth_getTransactionsByBlockNumberAndIndex.
Key | Type | Value |
---|---|---|
blockHash |
Data, 32 bytes | Hash of block containing this transaction. null when transaction is pending. |
blockNumber |
Quantity | Block number of block containing this transaction. null when transaction is pending. |
from |
Data, 20 bytes | Address of the sender. |
gas |
Quantity | Gas provided by the sender. |
gasPrice |
Quantity | Gas price provided by the sender in Wei. |
hash |
Data, 32 bytes | Hash of the transaction. |
input |
Data | Data sent with the transaction. |
nonce |
Quantity | Number of transactions made by the sender before this one. |
to |
Data, 20 bytes | Address of the receiver. null if a contract creation transaction. |
transactionIndex |
Quantity, Integer | Index position of transaction in the block. null when transaction is pending. |
value |
Quantity | Value transferred in Wei. |
v |
Quantity | ECDSA Recovery ID |
r |
Data, 32 bytes | ECDSA signature r |
s |
Data, 32 bytes | ECDSA signature s |
Parameter for eth_call and eth_estimateGas.
Note: All parameters are optional for eth_estimateGas
Key | Type | Required/Optional | Value |
---|---|---|---|
from |
Data, 20 bytes | Optional | Address from which transaction sent. |
to |
Data, 20 bytes | Required | Address to which transaction is directed. |
gas |
Quantity, Integer | Optional | Gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. |
gasPrice |
Quantity, Integer | Optional | gasPrice used for each paid gas. |
value |
Quantity, Integer | Optional | Value sent with this transaction. |
data |
Data | Optional | Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI. |
Returned by eth_getTransactionReceipt.
Key | Type | Value |
---|---|---|
blockHash |
Data, 32 bytes | Hash of block containing this transaction. |
blockNumber |
Quantity | Block number of block containing this transaction. |
contractAddress |
Data, 20 bytes | Contract address created, if contract creation transaction; otherwise, null . |
cumulativeGasUsed |
Quantity | Total amount of gas used by previous transactions in the block and this transaction. |
from |
Data, 20 bytes | Address of the sender. |
gasUsed |
Quantity | Amount of gas used by this specific transaction. |
logs |
Array | Array of log objects generated by this transaction. |
logsBloom |
Data, 256 bytes | Bloom filter for light clients to quickly retrieve related logs. |
status |
Quantity | Either 1 (success) or 0 (failure) |
to |
Data, 20 bytes | Address of the receiver, if sending ether; otherwise, null. |
transactionHash |
Data, 32 bytes | Hash of the transaction. |
transactionIndex |
Quantity, Integer | Index position of transaction in the block. |
Note: For pre-Byzantium transactions, the transaction receipt object includes the following instead of status
:
Key | Type | Value |
---|---|---|
root |
Data, 32 bytes | Post-transaction stateroot |