crates/aptos-rosetta/README.md
This implementation is built for running a local proxy against a local fullnode. However, for testing purposes, this can be used against an external REST endpoint.
Rosetta works as a sidecar to an Aptos fullnode. Rosetta then proxies the Rosetta standard API calls to underlying Aptos REST API calls and builds the appropriate data.
The aptos-rosetta binary can run in three modes:
online -> This runs a local fullnode and blocks the Aptos REST API from outside access, using it only as a local proxy for Rosetta APIs.offline -> This runs a Rosetta server that is not connected to the blockchain. Only commands listed as offline work with this mode.online-remote -> This runs a Rosetta instance that connects to a remote fullnode e.g. a public fullnode. Please keep in mind that since this proxies APIs, it can fail due to throttling and network errors between the servers.APT is supported.stake, and only with 0x1::staking_contract stake pools.get_account_resources; and if the block has been pruned, it will error out.block.Blocks support reading the following operations:
create_account -> When an account is created.withdraw -> When a balance is withdrawn from an account.deposit -> When a balance is deposited to an account.fee -> The gas fee associated with running a transaction.set_operator -> Switching a 0x1::staking_contract operator to a new operator.set_voter -> Switching a 0x1::staking_contract voter to a new voter.Here are some exceptions:
failed transactions.All transactions are parsed from the events provided by the AptosFramework. There are a few exceptions to this that use the transaction payload, but only for errors.
Block hash is <chain_id>:<block_height> and not actually a hash.
More specifics can be found here: https://www.rosetta-api.org/docs/flow.html#construction-api
All inputs to the API must be done in the ConstructionPreprocessRequest. This allows you to set
the sequence number, expiry time, gas parameters, and the public keys to sign the transaction.
Note: Currently only single signer is supported at this time.
The general flow is that you provide these inputs and follow the flow of APIs. The Metadata call
will do a simulation of the transaction and tell you the estimated gas fee for that transaction. It
will also fail the transaction before paying gas if the transaction cannot work. Once all the payloads
are built and combined, you must sign the transaction with the Ed25519 key that matches the PublicKey
provided in the ConstructinoPreProcessRequest.
create_account operation alone.withdraw and a deposit. This has the side effect of creating the receiver if it doesn't exist.All data types must hide null values from the output JSON. Additionally, u64s must be
encoded as strings in any metadata fields.
All errors are 500s and have error codes that are static and must not change. To add more errors, add new codes and associated data. The error details must not show in the network options call and are all provided as Option<String> for that reason.
All timestamps are valid except for the first two timestamps. These are generally 0, so they are set to January 1st 2000 if they're older than that.
Mempool APIs are currently not supported.
The Rosetta CLI can be run with the rosetta_cli.json file to run the automated checks. Additionally, the aptos.ros file uses the Rosetta CLI DSL to describe the possible operations that can be run.
Additionally, we have our aptos-rosetta-cli crate for local testing.