Skip to content

Commit 786fe3b

Browse files
committed
Sample docs from Nextra
1 parent 8ec09b3 commit 786fe3b

File tree

297 files changed

+46819
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+46819
-1
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const config = [
2727
"**/pnpm-lock.yaml",
2828
"**/public",
2929
"**/scripts/migration",
30+
"**/nextra-migration",
3031
],
3132
},
3233

src/content/docs/build/apis.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: "Aptos APIs"
3+
---
4+
5+
import { LinkCard, CardGrid, Card } from '@astrojs/starlight/components';
6+
7+
8+
9+
{/* import { Cards, Card } from '@components/index' */}
10+
11+
# Aptos APIs
12+
13+
The Aptos Blockchain network can be accessed by several APIs, depending on your use-case.
14+
15+
## Aptos Fullnode
16+
17+
This API - embedded into Fullnodes - provides a simple, low latency, yet low-level way of _reading_ state and
18+
_submitting_ transactions to the Aptos Blockchain. It also supports transaction simulation.
19+
20+
<CardGrid>
21+
<LinkCard href="./apis/fullnode-rest-api-reference?network=mainnet" title="Aptos Fullnode REST API (Mainnet)" description={"Mainnet API playground for Aptos Fullnode REST API"} />
22+
<LinkCard href="./apis/fullnode-rest-api-reference?network=testnet" title="Aptos Fullnode REST API (Testnet)" description={"Testnet API playground for Aptos Fullnode REST API"} />
23+
<LinkCard href="./apis/fullnode-rest-api-reference?network=devnet" title="Aptos Fullnode REST API (Devnet)" description={"Devnet API playground for Aptos Fullnode REST API"} />
24+
</CardGrid>
25+
26+
## Indexer
27+
28+
<CardGrid>
29+
<LinkCard href="./indexer" title="Indexer GraphQL API" description={"This GraphQL API offers a high-level, opinionated GraphQL interface to read state from the Aptos Blockchain. It's ideal for interacting with NFTs, Aptos Objects, or custom Move contracts. Learn more about the Indexer-powered GraphQL API here."} />
30+
<LinkCard href="./indexer/txn-stream" title="Transaction Stream API" description={"This GRPC API streams historical and real-time transaction data to an indexing processor. It's used by Aptos Core Indexing and can also support custom app-specific indexing processors for real-time blockchain data processing. Learn more here."} />
31+
</CardGrid>
32+
33+
## Faucet (Only Testnet/Devnet)
34+
35+
<CardGrid>
36+
<LinkCard href="./apis/faucet-api" title="Faucet API" description={"This API provides the ability to receive test tokens on devnet. Its primary purpose is the development and testing of applications and Move contracts before deploying them to mainnet. On testnet you can mint at the [mint page](/network/faucet)."} />
37+
</CardGrid>
38+
39+
40+
The code of each of the above-mentioned APIs is open-sourced on [GitHub](https://github.com/aptos-labs/aptos-core). As
41+
such anyone can operate these APIs and many independent operators and builders worldwide choose to do so.
42+
43+
### Aptos Labs operated API Deployments
44+
45+
[Aptos Labs](https://aptoslabs.com) operates a deployment of these APIs on behalf of [Aptos Foundation](https://aptosfoundation.org/)
46+
for each [Aptos Network](../network/nodes/networks.mdx) and makes them available for public consumption.
47+
48+
At the moment there are 2 sets of Aptos Labs API deployments:
49+
50+
1. [APIs with anonymous access and IP-based rate-limiting](../network/nodes/networks.mdx)
51+
2. [[Beta] APIs with authentication and developer-account based rate limiting through the Aptos Labs Developer Portal](apis/aptos-labs-developer-portal.mdx)
52+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: "Aptos Labs API Gateway"
3+
---
4+
5+
import { Aside } from '@astrojs/starlight/components';
6+
7+
8+
9+
# Aptos Labs API Gateway
10+
11+
<Aside type="note">
12+
API Gateway is currently in beta. Please report any problems you encounter
13+
by creating an [issue in the aptos-core](https://github.com/aptos-labs/aptos-core/issues/new?assignees=@geekflyer,@dport,@blakezimmerman&labels=api-gateway&projects=&template=dev_portal_issue.md&title=%5BDev+Portal%5D) repo.
14+
</Aside>
15+
16+
[API Gateway](https://developers.aptoslabs.com) is your gateway to access Aptos Labs provided APIs in a quick and easy fashion to power your dapp. It consists of a Portal (UI) and a set of API Gateways operated by Aptos Labs.
17+
18+
Learn more about API Gateway at the dedicated [API Gateway docs site](https://developers.aptoslabs.com/docs).
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "Data Providers"
3+
---
4+
5+
6+
7+
8+
# Data Providers
9+
10+
If you want to access aptos blockchain data but don't need it in real-time.
11+
We have a few options that will let you access this data using SQL or UIs for building dashboards.
12+
This type of data is often used for analytics since it allows for aggregations.
13+
14+
## Review of data endpoints
15+
16+
Hitting the full node directly will give the latest data (will be missing historical unless it's an archival full node) using [REST API](../apis.mdx#aptos-fullnode)
17+
18+
Indexer layer on top of this will provide a [GRPC transaction stream](../indexer/txn-stream/aptos-hosted-txn-stream)
19+
20+
On top of this transaction stream, we've built out some product logic tables that can be queried through [GraphQL](../indexer/)
21+
22+
Since the logic to parse out transaction is [public](https://github.com/aptos-labs/aptos-indexer-processors), some vendors have implemented similar parsing logic to create a subset of tables and made them available to query.
23+
24+
## SQL Tables
25+
26+
Indexer defines several processors that create different database tables.
27+
28+
### Core tables
29+
30+
These are parsed directly from node API response, one option is to split it out into the following tables:
31+
32+
- Blocks - version, block height, epoch, timestamp
33+
- Transactions - version, sender, entry function, gas
34+
- Signatures - signature types, signer, fee payer address
35+
- Events - type and data for events
36+
37+
We store data as table items, resources or modules
38+
39+
- (write set) changes - change index, change type, resource address
40+
- Table items - table key, table handle, key (content and type), value (content and type)
41+
- (move) resources - resource address, resource type, data
42+
- (move) modules - bytecode for deployed modules
43+
44+
## Vendors of off-chain data
45+
46+
Most of our data vendors only provide core datasets.
47+
A [subset of vendors](https://aptosfoundation.org/currents/aptos-on-chain-data-capabilities-with-dune-nansen-and-other-providers) is listed below
48+
49+
### Google bigquery public dataset
50+
51+
Provides data through [google public data](https://console.cloud.google.com/marketplace/product/bigquery-public-data/crypto-aptos-mainnet-us)
52+
53+
![bq_sql](/screenshots/bq_sql.png)
54+
55+
We also have sample analytics queries [using the above resources](https://github.com/aptos-labs/explorer/tree/main/analytics)
56+
57+
### Dune
58+
59+
We have a dashboard here: https://dune.com/aptos/aptos-chain-metrics-overview
60+
61+
### Flipside
62+
63+
Another dashboard vendor, signatures in core tables were merged into `fact_transactions`
64+
They also have a few more convenience tables (defi, nft, price), [table list](https://flipsidecrypto.github.io/aptos-models/#!/overview)
65+
66+
### Artemis
67+
68+
Provides [topline metrics](https://app.artemis.xyz/project/aptos) as well as chart builder
69+
70+
### Nansen
71+
72+
Provides [topline metrics](https://app.nansen.ai/macro/blockchains?chain=aptos) with additional functionality with account.
73+
74+
### Allium
75+
76+
Raw data is available: https://docs.allium.so/historical-data/supported-blockchains/move-ecosystem/aptos
77+
78+
### Sentio
79+
80+
They have a guide here: https://docs.sentio.xyz/docs/aptos
81+
Data is found in data source -> external project -> sentio/aptos-overview
82+
They also provide stack tracing of transactions
83+
84+
### Space and Time
85+
86+
Data can be found here: https://app.spaceandtime.ai/data-sets?selectedChain=aptos
87+
They also have some non-core tables (Token, Staking, etc)
88+
89+
## Other vendors
90+
91+
We also have some partners who target more enterprise use cases
92+
93+
- [Token Terminal](https://tokenterminal.com/resources/articles/aptos-data-partnership)
94+
- [The Tie](https://www.thetie.io/insights/news/introducing-aptos-ecosystem-dashboard-and-on-chain-data/)
95+
- [Elliptic](https://www.elliptic.co/media-center/elliptic-partners-with-aptos-foundation-as-a-data-integration-provider-to-offer-compliance-screening-and-risk-services-for-aptos-network)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: "Faucet API"
3+
---
4+
5+
6+
7+
8+
# Faucet API
9+
10+
The faucet allows users to get `APT` on devnet. On testnet you can only mint at the [mint page](/network/faucet). It is not available on Mainnet.
11+
12+
The endpoints for each faucet are:
13+
14+
- Devnet: https://faucet.devnet.aptoslabs.com
15+
16+
## Using the faucet
17+
18+
Each SDK has integration for devnet to use the faucet. Below are a few examples, but you can
19+
see more information on each individual [SDK's documentation](../sdks.mdx).
20+
21+
### Using the faucet in a wallet
22+
23+
Most wallets, such as [Petra](https://aptosfoundation.org/ecosystem/project/petra) or [Pontem](https://aptosfoundation.org/ecosystem/project/pontem-wallet)
24+
will have a faucet button for devnet. See full list of [Aptos Wallets](https://aptosfoundation.org/ecosystem/projects/wallets).
25+
26+
### Using the faucet in the Aptos CLI
27+
28+
Once you've [set up your CLI](../cli/setup-cli.mdx), you can simply call fund-with-faucet. The amount used is in Octas (1 APT = 100,000,000 Octas).
29+
30+
```bash filename="Terminal"
31+
aptos account fund-with-faucet --account 0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6 --amount 100000000
32+
```
33+
34+
### Using the faucet in the TypeScript SDK
35+
36+
Here is an example funding the account `0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6` with 1 APT in Devnet. The amount used is in Octas (1 APT = 100,000,000 Octas).
37+
38+
```ts filename="index.ts"
39+
import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
40+
41+
const aptos = new Aptos(new AptosConfig({network: Network.Devnet}));
42+
aptos.fundAccount({accountAddress: "0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", amount: 100000000});
43+
```
44+
45+
### Using the faucet in the Go SDK
46+
47+
Here is an example funding the account `0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6` with 1 APT in Devnet. The amount used is in Octas (1 APT = 100,000,000 Octas).
48+
49+
```go filename="index.go"
50+
import "github.com/aptos-labs/aptos-go-sdk"
51+
52+
func main() {
53+
client, err := aptos.NewClient(aptos.LocalnetConfig)
54+
if err != nil {
55+
panic(err)
56+
}
57+
58+
client.Fund("0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6", 100000000)
59+
}
60+
```
61+
62+
### Calling the faucet: Other languages not supported by SDKs
63+
64+
If you are trying to call the faucet in other languages, you have two options:
65+
66+
1. Generate a client from
67+
the [OpenAPI spec](https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-faucet/doc/spec.yaml).
68+
2. Call the faucet on your own.
69+
70+
For the latter, you will want to build a query similar to this:
71+
72+
```bash filename="Terminal"
73+
curl -X POST
74+
'https://faucet.devnet.aptoslabs.com/mint?amount=10000&address=0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6'
75+
```
76+
77+
This means mint 10000 [octas](../../network/glossary.mdx#Octa) to
78+
address `0xd0f523c9e73e6f3d68c16ae883a9febc616e484c4998a72d8899a1009e5a89d6`.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: "Aptos Fullnode REST API"
3+
---
4+
5+
import { LinkCard, Aside, CardGrid, Card } from '@astrojs/starlight/components';
6+
7+
8+
9+
{/* import { Card, Cards } from '@components/index' */}
10+
11+
# Aptos Fullnode REST API
12+
13+
This API - embedded into Fullnodes - provides a simple, low latency, yet low-level way of reading state and submitting transactions to the Aptos Blockchain. It also supports transaction simulation.
14+
For more advanced queries, we recommend using the [Indexer GraphQL API](../indexer.mdx).
15+
16+
## Fullnode REST API Explorer
17+
18+
<CardGrid>
19+
<LinkCard href="https://fullnode.mainnet.aptoslabs.com/v1/spec#/" title="Mainnet Fullnode REST API" description={"REST API Explorer for Mainnet"} />
20+
<LinkCard href="https://fullnode.testnet.aptoslabs.com/v1/spec#/" title="Testnet Fullnode REST API" description={"REST API Explorer for Testnet"} />
21+
<LinkCard href="https://fullnode.devnet.aptoslabs.com/v1/spec#/" title="Devnet Fullnode REST API" description={"REST API Explorer for Devnet"} />
22+
</CardGrid>
23+
24+
## Understanding rate limits
25+
26+
As with the [Aptos Indexer](../indexer/indexer-api.mdx), the Aptos REST API has a rate limit of 5000
27+
requests per five minutes by IP address, whether submitting transactions or querying the API on Aptos-provided nodes.
28+
(As a node operator, you may raise those limits on your own node.) Note that this limit can change with or without prior
29+
notice.
30+
31+
## Viewing current and historical state
32+
33+
Most integrations into the Aptos blockchain benefit from a holistic and comprehensive overview of the current and
34+
historical state of the blockchain. Aptos provides historical transactions, state, and events, all the result of
35+
transaction execution.
36+
37+
- Historical transactions specify the execution status, output, and tie to related events. Each transaction has a unique
38+
version number associated with it that dictates its global sequential ordering in the history of the blockchain ledger.
39+
- The state is the representation of all transaction outputs up to a specific version. In other words, a state version
40+
is the accumulation of all transactions inclusive of that transaction version.
41+
- As transactions execute, they may emit events. [Events](../../network/blockchain/events.mdx) are hints about changes in on-chain
42+
data.
43+
44+
<Aside type="note">
45+
Ensure the [fullnode](../../network/nodes/networks.mdx) you are communicating with is up-to-date. The fullnode must reach the
46+
version containing your transaction to retrieve relevant data from it. There can be latency from the fullnodes
47+
retrieving state from [validator fullnodes](../../network/blockchain/fullnodes.mdx), which in turn rely upon
48+
[validator nodes](../../network/blockchain/validator-nodes.mdx) as the source of truth.
49+
</Aside>
50+
51+
The storage service on a node employs two forms of pruning that erase data from nodes:
52+
53+
- state
54+
- events, transactions, and everything else
55+
56+
While either of these may be disabled, storing the state versions is not particularly sustainable.
57+
58+
Events and transactions pruning can be disabled via setting the [`enable_ledger_pruner`](https://github.com/aptos-labs/aptos-core/blob/cf0bc2e4031a843cdc0c04e70b3f7cd92666afcf/config/src/config/storage_config.rs#L141)
59+
to `false` in `storage_config.rs`. This is default behavior in Mainnet. In the near future, Aptos will provide indexers
60+
that mitigate the need to directly query from a node.
61+
62+
The REST API offers querying transactions and events in these ways:
63+
64+
- [Transactions for an account](https://api.devnet.aptoslabs.com/v1/spec#/operations/get_account_transactions)
65+
- [Transactions by version](https://api.devnet.aptoslabs.com/v1/spec#/operations/get_transaction_by_version)
66+
- [Events by event handle](https://api.devnet.aptoslabs.com/v1/spec#/operations/get_events_by_event_handle)
67+
68+
## Reading state with the View function
69+
70+
View functions do not modify blockchain state when called from the API. A [View function](https://github.com/aptos-labs/aptos-core/blob/main/api/src/view_function.rs)
71+
and its [input](https://github.com/aptos-labs/aptos-core/blob/main/api/types/src/view.rs) can be used to read
72+
potentially complex on-chain state using Move. For example, you can evaluate who has the highest bid in an auction
73+
contract. Here are related files:
74+
75+
- [`view_function.rs`](https://github.com/aptos-labs/aptos-core/blob/main/api/src/tests/view_function.rs) for an example
76+
- related [Move](https://github.com/aptos-labs/aptos-core/blob/90c33dc7a18662839cd50f3b70baece0e2dbfc71/aptos-move/framework/aptos-framework/sources/coin.move#L226) code
77+
- [specification](https://github.com/aptos-labs/aptos-core/blob/90c33dc7a18662839cd50f3b70baece0e2dbfc71/api/doc/spec.yaml#L8513).
78+
79+
The view function operates like the Aptos simulation API,
80+
though with no side effects and an accessible output path. View functions can be called via the `/view` endpoint. Calls
81+
to view functions require the module and function names along with input type parameters and values.
82+
83+
A function does not have to be immutable to be tagged as `#[view]`, but if the function is mutable it will not result in
84+
state mutation when called from the API. If you want to tag a mutable function as `#[view]`, consider making it private
85+
so that it cannot be maliciously called during runtime.
86+
87+
In order to use the View functions, you need to [publish the module](../cli/working-with-move-contracts.mdx)
88+
through the [Aptos CLI](../cli.mdx).
89+
90+
In the Aptos CLI, a view function request would look like this:
91+
92+
```bash filename="Terminal"
93+
aptos move view --function-id devnet::message::get_message --profile devnet --args address:devnet
94+
{
95+
"Result": [
96+
"View functions rock!"
97+
]
98+
}
99+
```
100+
101+
In the TypeScript SDK, a view function request would look like this:
102+
103+
```ts filename="index.ts"
104+
import { Aptos } from "@aptos-labs/ts-sdk";
105+
106+
const aptos = new Aptos();
107+
const [balance] = aptos.view<[string]>({
108+
function: "0x1::coin::balance",
109+
typeArguments: ["0x1::aptos_coin::AptosCoin"],
110+
functionArguments: [alice.accountAddress]
111+
});
112+
113+
expect(balance).toBe("100000000");
114+
```
115+
116+
The view function returns a list of values as a vector. By default, the results are returned in JSON format; however,
117+
they can be optionally returned in Binary Canonical Serialization (BCS) encoded format.

0 commit comments

Comments
 (0)