Fork APIs

Using APIs to Manage Forks
Phalcon supports managing Forks through Fork API. The request is in HTTP POST with an access key embedded in the header. The Access key used in the API is shown in the Account Card of the Forks Dashboard. The requested data is packed in the data field of the body. The response is in JSON format, with the following common structure.
  • code: Integer. Error code.
    • 0: No error.
    • other: Error occurs.
  • message: String
    • If the code is not 0, this field denotes the detailed error information.
  • data: JSON
    • This is the detailed response data.

Create a Fork

This API is used to create a Fork.
post
https://api.phalcon.xyz/v1/fork/list
Create a Fork from the specified block height and position.
Request
Response
curl --location 'https://api.phalcon.xyz/v1/fork/create' \
--header 'Access-Key: $AccessKey' \
--header 'Content-Type: application/json' \
--data '{
"chainId":1,
"height": "safe",
"name":"testApiFork",
"position":20,
"antiReplay": true
}'
{
"code": 0,
"message": "OK",
"data": {
"forkId": "b480224a-8e0f-4e90-9e47-6017c7bdxxxx",
"chainId": 9991,
"name": "testApiFork111",
"snapshotId": "b480224a-8e0f-4e90-9e47-6017c7bdadaa",
"rpc": "https://rpc.phalcon.xyz/xxxxxxxxfd2a4e5ca1179785xxxxxxxx"
}
}

Request

  • height: It specifies the block height that the chain is forked from. It accepts the following options.
    • HEX String - an integer block number
    • String "safe" - for the latest safe head block
  • position: Integer. The position in the block (specified by height) that the Forked chain starts.
  • name: String. The name of the created Fork.
  • `antiReplay`: Boolean. It specifies whether the anti-replay feature is enabled for this Fork.

Response

  • forkId: String. The id of the created Fork. This id is used to manipulate a Fork (e.g., delete a Fork).
  • chainId: Integer. The id of the chain that is forked. It should be the same as the chainId passed in the request.
  • name: String. The name of the Fork. It should be the same as the name passed in the request.
  • snapshotId: String. The id of the default snapshot of this Fork.

Delete a Fork

This API is used to delete a Fork.
post
https://api.phalcon.xyz/v1/fork/delete
Request
Response
curl --location 'https://api.phalcon.xyz/v1/fork/delete' \
--header 'Access-Key: $AccessKey' \
--header 'Content-Type: application/json' \
--data '{
"forkId": "296b480c-6d61-4b46-8a4c-8ae0d2d3xxxx"
}'
{
"code": 0,
"message": "OK"
}

Request

  • forkId: String. The id of the Fork that is to be deleted.

Query Fork List

This API is used to retrieve a list of Forks.
post
https://api.phalcon.xyz/v1/fork/list
Request
Response
curl --location --request POST 'https://api.phalcon.xyz/v1/fork/list' \
--header 'Access-Key: {{AccessKey}}'
{
"code": 0,
"data": [
{
"forkId": "621bf83d-9741-xxx-92c7-acdcc1399055",
"name": "1",
"rpc": "https://rpc.phalcon.xyz/xxx",
"chainId": 9991
},
{
"forkId": "3dbeb3a1-b3b4-xxx-91ea-c160a347a781",
"name": "ETH1",
"rpc": "https://rpc.phalcon.xyz/xxx",
"chainId": 1
},
{
"forkId": "f11f7186-a57a-xxx-b849-177577a1c130",
"name": "eth",
"rpc": "https://rpc.phalcon.xyz/xxx",
"chainId": 1
}
]
}

Response

  • forkId: String. The id of the created Fork. This id is used to manipulate a Fork (e.g., delete a Fork).
  • chainId: Integer. The id of the chain that is forked. It should be the same as the chainId passed in the request.
  • name: String. The name of the Fork. It should be the same as the name passed in the request.

Query Fork Usage Status

This API is used to retrieve the usage status of a Fork.
post
https://api.phalcon.xyz/v1/fork/usage
Request
Response
curl --location 'https://api.phalcon.xyz/v1/fork/usage' \
--header 'Access-Key: $AccessKey' \
{
"code": 0,
"data": {
"currentUsage": {
"forks": 1,
"transactionPerDay": 0,
"transactionPerMonth": 0
},
"totalPlanned": {
"forks": 5,
"transactionPerDay": 50,
"transactionPerMonth": 50
}
}
}

Response

  • currentUsage: Object. The current usage status.
    • forks: Integer. The number of Forks currently in use.
    • transactionPerDay: Integer. The number of transactions per day.
    • transactionPerMonth: Integer. The number of transactions per month.
  • totalPlanned: Object. The total planned usage.
    • forks: Integer. The number of Forks planned to be used.
    • transactionPerDay: Integer. The number of transactions planned per day.
    • transactionPerMonth: Integer. The number of transactions planned per month.