Deprecating Ortelius
This guide explains how to replace usage of the Ortelius API with other APIs, including AvalancheGo's Index API. Ortelius is deprecated. You should use other AvalancheGo APIs to get the information that you used to get from Ortelius.

Index API

AvalancheGo can be configured to run with an indexer. That is, it saves (indexes) every container (a block, vertex or transaction) it accepts on the X-Chain, P-Chain and C-Chain. To run AvalancheGo with indexing enabled, use command line flag --index-enabled. AvalancheGo will only index containers that are accepted when running with --index-enabled. For more information, see the Index API documentation. Please be sure to read the Index API documentation in its entirety.
Below, we provide instructions on how to use the Index API to:
  • Get the total number of blocks/transactions that have been accepted
  • Get a block/transaction by its ID

Get Total Block/Transaction Count

You can use the Index API to get the number of blocks/vertices/transactions that have been accepted on a given chain. You can use curl or the the Index API Client's getLastAccepted method to accomplish this.
In the examples below, we're getting the number of X-Chain transactions that have been accepted.
  • To get the number of accepted C-Chain blocks, replace /ext/index/X/tx with /ext/index/C/block below.
  • To get the number of accepted P-Chain blocks, replace /ext/index/X/tx with /ext/index/P/block.
  • To get the number of accepted X-Chain vertices, replace /ext/index/X/tx with /ext/index/X/vtx.

Index API Client

1
package main
2
3
import (
4
"fmt"
5
"time"
6
7
"github.com/ava-labs/avalanchego/indexer"
8
"github.com/ava-labs/avalanchego/utils/formatting"
9
)
10
11
func main() {
12
client := indexer.NewClient("http://localhost:9650", "/ext/index/X/tx", 5*time.Second)
13
args := &indexer.GetLastAcceptedArgs{Encoding: formatting.Hex}
14
container, err := client.GetLastAccepted(args)
15
if err != nil {
16
panic(err)
17
}
18
fmt.Printf("%d transactions have been accepted", container.Index+1)
19
}
Copied!

curl

You can use curl to get the number of blocks/vertices/transactions that have been accepted on a given chain.
Example Call
1
curl --location --request POST 'http://localhost:9650/ext/index/X/tx' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{
4
"jsonrpc": "2.0",
5
"method": "index.getLastAccepted",
6
"params": {
7
"encoding":"hex"
8
},
9
"id": 1
10
}' | jq
Copied!
Example Response
(Note that the bytes field has been truncated for brevity.)
1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"id": "2W1vuBmkapdCfRXMKbUH6BQCaTycrztxkuuBPdAfe96DanCvqZ",
5
"bytes": "0x00000000000000000001ed5f383...",
6
"timestamp": "2021-10-21T20:55:27.616393152Z",
7
"encoding": "hex",
8
"index": "2683522"
9
},
10
"id": 1
11
}
Copied!
The ID of the most recently accepted X-Chain transaction is 2W1vuBmkapdCfRXMKbUH6BQCaTycrztxkuuBPdAfe96DanCvqZ. Since the index of the last accepted transaction is 2683522, this means 2683523 X-Chain transactions have been accepted.

Get a Transaction/Block/Vertex by ID

You can get containers by their ID using the Index API. You can also use chain-specific APIs.

Index API Client

The snippet below uses the Index API Client's getContainerByID method to get an X-Chain container by its ID.
  • To get a C-Chain block, replace /ext/index/X/tx with /ext/index/C/block below.
  • To get a P-Chain block, replace /ext/index/X/tx with /ext/index/P/block.
  • To get an X-Chain vertex, replace /ext/index/X/tx with /ext/index/X/vtx.
1
package main
2
3
import (
4
"fmt"
5
"time"
6
7
"github.com/ava-labs/avalanchego/ids"
8
"github.com/ava-labs/avalanchego/indexer"
9
"github.com/ava-labs/avalanchego/utils/formatting"
10
)
11
12
func main() {
13
client := indexer.NewClient("http://localhost:9650", "/ext/index/X/tx", 5*time.Second)
14
containerID, err := ids.FromString("2W1vuBmkapdCfRXMKbUH6BQCaTycrztxkuuBPdAfe96DanCvqZ")
15
if err != nil {
16
panic(err)
17
}
18
args := &indexer.GetIndexArgs{
19
ContainerID: containerID,
20
Encoding: formatting.Hex,
21
}
22
container, err := client.GetContainerByID(args)
23
if err != nil {
24
panic(err)
25
}
26
containerBytes, err := formatting.Decode(container.Encoding, container.Bytes)
27
if err != nil {
28
panic(err)
29
}
30
fmt.Printf("container: %v\n", containerBytes)
31
}
Copied!
curl example of getContainerByID can be found here.

Chain-Specific APIs

X-Chain

You can use X-Chain API method avm.getTx to get an X-Chain transaction by its ID. Set encoding to json to get a human-readable JSON response.
Example Call
1
curl -X POST --data '{
2
"jsonrpc":"2.0",
3
"id" :1,
4
"method" :"avm.getTx",
5
"params" :{
6
"txID":"2W1vuBmkapdCfRXMKbUH6BQCaTycrztxkuuBPdAfe96DanCvqZ",
7
"encoding": "json"
8
}
9
}' -H 'content-type:application/json;' http://localhost:9650/ext/bc/X | jq
Copied!
Example Response
1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"tx": {
5
"unsignedTx": {
6
"networkID": 1,
7
"blockchainID": "2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM",
8
"outputs": [
9
{
10
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
11
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
12
"output": {
13
"addresses": [
14
"X-avax1c284te00gjeph54wh8jy5zdlc5k6qjkkgjuz5g"
15
],
16
"amount": 50000000000,
17
"locktime": 0,
18
"threshold": 1
19
}
20
},
21
{
22
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
23
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
24
"output": {
25
"addresses": [
26
"X-avax1pgqxa6qw87wajaezvu02myyy8cctjl5y3hv02s"
27
],
28
"amount": 55027917498,
29
"locktime": 0,
30
"threshold": 1
31
}
32
}
33
],
34
"inputs": [
35
{
36
"txID": "23D2DrDg4apGW7sz3gGEXkx6wz4wMkuT8ru7s39p8K5vyvkinz",
37
"outputIndex": 1,
38
"assetID": "FvwEAhmxKfeiG8SnEvq42hc6whRyY3EFYAvebMqDNDGCgxN5Z",
39
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
40
"input": {
41
"amount": 105028917498,
42
"signatureIndices": [
43
0
44
]
45
}
46
}
47
],
48
"memo": "0x43727974706f2e636f6d"
49
},
50
"credentials": [
51
{
52
"fxID": "spdxUxVJQbX85MGxMHbKw1sHxMnSqJ3QBzDyDYEP3h6TLuxqQ",
53
"credential": {
54
"signatures": [
55
"0x5943457d6a7e370e0ed239715f04bf4ba7545a9d3440a848d52db97aece6f51c7c87ba9aa944327f63dd39feeec9ad978b23855fe1b081bc7159a2d4f8f027b600"
56
]
57
}
58
}
59
]
60
},
61
"encoding": "json"
62
},
63
"id": 1
64
}
Copied!

P-Chain

You can use P-Chain API method platform.getTx to get a P-Chain transaction by its ID.

C-Chain

You can use the C-Chain's API to get a transaction by its ID, a block by its ID, or a block by its height. See eth_getTransactionByHash, eth_getBlockByHash and eth_getBlockByNumber here.
Last modified 19d ago