Papyrus
Papyrus is a StarkNet full node written in Rust.
Install / Use
/learn @starkware-libs/PapyrusREADME
= Archived
This repository is archived and no longer maintained.
The functionality of this repository has been integrated into the https://github.com/starkware-libs/sequencer[Starknet sequencer reposiroty].
:toc: :toclevels: 4 [pass] ++++
<div align="center"> ++++ = Papyrus A Starknet full nodeimage::./resources/img/papyrus-logo-square.png[Papyrus logo,200,200, align="center"]
link:https://github.com/starkware-libs/papyrus/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+[Report a Bug] · link:https://github.com/starkware-libs/papyrus/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feat%3A+"[Request a Feature] · link:https://github.com/starkware-libs/papyrus/discussions"[Ask a Question]
image:https://img.shields.io/github/actions/workflow/status/starkware-libs/papyrus/ci.yml?branch=main[Github workflow status] image:https://img.shields.io/github/license/starkware-libs/papyrus.svg?style=flat-square[#LICENSE,title=Project license] image:https://img.shields.io/badge/PRs-welcome-ff69b4.svg?style=flat-square[PRs welcome,link=https://github.com/starkware-libs/papyrus/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22] image:https://codecov.io/gh/starkware-libs/papyrus/branch/main/graph/badge.svg?token=YZA9IPDHRM[codecov,link=https://codecov.io/gh/starkware-libs/papyrus] [pass] ++++
</div> ++++== About
Papyrus is a Starknet full node implemented in Rust. Papyrus tracks Starknet’s state as it evolves over time, and enables you to query this state and to execute transactions via Starknet’s JSON-RPC.
=== Supported Starknet versions
This Papyrus version supports the following starknet versions:
- v0.13.0
== Disclaimer
Papyrus is a work in progress.
Use it at your own risk.
== Getting started
[#compiling-and-running-papyrus] === Building and running Papyrus locally
[discrete] ==== Prerequisites
- https://www.rust-lang.org/tools/install[Rust] must be installed. Minimum supported version is
1.76. - You must have access to an Ethereum node. For example, you can use a node provider such as Infura.
[discrete] ==== Procedure
. Fork and clone the Github repo. . Build and run a Papyrus node with the default configuration by running the following commands: + [source,bash]
mkdir data cargo run --release --package papyrus_node --bin papyrus_node -- --base_layer.node_url <ethereum_node_url>
[NOTE]
Papyrus uses the data directory for the node's storage, as follows:
./data/<chain_id>
You can configure the directory name using the storage.db_config.path_prefix configuration parameter.
. See the version of Papyrus by running the following command: + [source,bash]
cargo run --release --package papyrus_node --bin papyrus_node -- --version
=== Local node configuration
The configuration is stored in one or more configuration files in .json format.
The default Papyrus configuration file, link:https://github.com/starkware-libs/papyrus/blob/main/config/default_config.json[default_config.json], includes descriptions of all available parameters.
// , including pointers to common values and #is_none flags for optional parameters.
=== Customizing your configuration
You can override the default configuration in the following ways:
- Refer to one or more custom configuration files, using the same format as the default configuration file,
default_config.json. For example, see any of the preset configuration files in this repository at/config/presets/. You can use configuration files when running a local node only, not a Docker image. - Include configuration options in the command line when you run Papyrus.
- Set environment variables in the command line when you run Papyrus.
==== Configuration files (local node only)
The following rules apply:
- You do not need to specify the default configuration file.
- There is no limit on the number of custom configuration files you use.
- If the same configuration parameter appears in multiple configuration files, the last file in the list determines the value.
You can create separate configuration files to override specific configuration parameters.
To create a custom configuration file, create a .json file using the same format as the default configuration file.
To specify custom configuration files, include the --config_file command-line option when you run the full node locally, as follows:
[source,bash,subs="verbatim,quotes"]
cargo run --release --package papyrus_node --bin papyrus_node -- --base_layer.node_url <ethereum_node_url> --config-file <path_to_custom_configuration_file_1> <path_to_custom_configuration_file___n__>
For example, preset .json files for several Starknet networks are located in this repository at https://github.com/starkware-libs/papyrus/blob/main/config/presets[/config/presets]. To use Sepolia testnet, you need to override the default values by using the file /config/presets/sepolia_testnet.json, as follows:
[source,bash,subs="verbatim,quotes"]
cargo run --release --package papyrus_node --bin papyrus_node -- --base_layer.node_url <ethereum_node_url> --config-file /config/presets/sepolia_testnet.json
==== Configuration via the command-line (local node and Docker image)
You can specify configuration parameters as command-line options. To see all available configuration parameters, enter the following command:
[source,bash]
cargo run --release --package papyrus_node --bin papyrus_node -- --help
For example, to use Sepolia testnet, run the following command:
[source,base,subs="verbatim,quotes"]
cargo run --release --package papyrus_node --bin papyrus_node -- --base_layer.node_url <ethereum_node_url>
--chain_id SN_SEPOLIA
--starknet_url https://alpha-sepolia.starknet.io/
--base_layer.starknet_contract_address 0xe2bb56ee936fd6433dc0f6e7e3b8365c906aa057
For more information, see the papyrus-config https://github.com/starkware-libs/papyrus/blob/main/crates/papyrus_config/README.md[README].
=== Running Papyrus with Docker
[discrete] ==== Prerequisites
- https://docs.docker.com/get-docker/[Docker] should be installed.
[discrete] ==== Procedure
. Make a local directory to use for the container’s data. You only need to complete this step the first time you run Papyrus. + [source,bash]
mkdir <local-host-data-path>
. Run a Papyrus node with the default configuration. You must explicitly give the container write access to the <local-host-data-path> directory by adding --user "$(id -u):$(id -g)" to the docker run command.
+
Enter the following command:
+
[source,bash]
docker run --rm --name papyrus
-p 8080-8081:8080-8081
-v /<local-host-data-path>:/app/data
ghcr.io/starkware-libs/papyrus:dev
--base_layer.node_url <ethereum_node_url>
--user "$(id -u):$(id -g)"
[NOTE]
You must include the dev, tag which tracks the development branch and contains the most up-to-date code. When an official release is available, you can use the latest tag for the latest release.
==== Upgrading the Docker container
Currently, there is no automatic upgrade mechanism. Make sure to periodically pull the latest image and re-run the node.
==== Docker container memory usage
The Papyrus node uses all available RAM in order to cache the storage.
If no other applications are running on your machine, this is the recommended configuration.
Otherwise, you can limit the node's memory usage by adding the --memory flag to run the node in a container with limited memory. Be aware that limiting the memory usage might make the node less efficient, as doing so decreases storage caching.
For example, to limit memory usage to 1GB, run the container with the following command:
[source,bash]
docker run --rm --name papyrus
-p 8080-8081:8080-8081
-v /<local-host-data-path>:/app/data
--memory 1g
ghcr.io/starkware-libs/papyrus:dev
--base_layer.node_url <ethereum_node_url>
--user "$(id -u):$(id -g)"
For more information, see https://docs.docker.com/config/containers/resource_constraints/#limit-a-containers-access-to-memory[Limit a container's access to memory] in the Docker documentation.
== Sending API requests to the node
When sending API requests, send them to the path /rpc/<starknet-rpc-version-id>.
Where <starknet-rpc-version-id> is one of the following strings:
v0_6v0_7
See the API specification at the https://github.com/starkware-libs/starknet-specs/[Starknet specifications repository] on Github. You can send API requests using the following command:
[source,bash]
curl --location '<node_path>/rpc/<starknet-rpc-version-id>' --header 'Content-Type: application/json'
--data '{"jsonrpc":"2.0","id":0,"method":"<method>", "params": "<params>"}'
For example, to send a request calling the starknet_getBlockTransactionCount method, on block number 100000, using the 0.4.0 version of the API where <node_path> is localhost:8080, use the following command:
[source,bash]
curl --location 'localhost:8080/rpc/v0_7_0' --header 'Content-Type: application/json'
--data '{"jsonrpc":"2.0","id":0,"method":"starknet_getBlockTransactionCount", "params": [{"block_number": 100000}] }'
== JSON RPC API endpoints
[cols=",,",] |=== |Endpoint |V0.6 |V0.7
|starknet_addDeclareTransaction |image:https://lh7-us.googleusercontent.com/g1om8QyIrLsSpgSiQ32w-Uk4ICU03_JeFYNwz8N9BfTviIMCN0DwKGGP_bDpX7pv_StNK9yWMQ39lZdNHn1o7xzcrBu1s0WHLAaBD2-nPqhMDGf2l9K6c67oIRV0kmIAQk580wcKhRSGpbj9qF1SVoQ[image,width=15,height=14]
|image:https://lh7-us.googleusercontent.com/g1om8QyIrLsSpgSiQ32w-Uk4ICU03_JeFYNwz8N9BfTviIMCN0DwKGGP_bDpX7pv_StNK9yWMQ39lZdNHn1o7xzcrBu1s0WHLAaBD2-nPqhMDGf2l9K6c67oIRV0kmIAQk580wcKhRSGpbj9qF1SVoQ[image,width=15,height=14]
|starknet_addDeployAccountTransaction |image:https://lh7-us.googleusercontent.com/B8OBZj3cblLUKbV6nRAmqPjzo86hmhw5XFBxYI8Xj1ZOpY6YoA3l-jiD2INst0aVVu7vsw3XBooNWfy-KulRi2ugDDG2XZpllKizcW
