Common Mistakes
Connecting to a Block Explorer
Any implementation of a Rosetta Server should connect exclusively to a running blockchain node in the same Dockerfile. It is not ok to connect to some external service that preprocesses blockchain data.
Using Swagger/OpenAPI 2 Tooling
In 2017, the OpenAPI Initiative published the OpenAPI 3.0 standard as a successor to the Swagger Specification. The Swagger Specification was then renamed to OpenAPI 2.0.
Not all tools developed for Swagger/OpenAPI 2.0 are compatible with this OpenAPI 3.0 format. Be sure to double check that any code you utilize to power your implementation is compatible.
Malformed Genesis Block
When populating the genesis block, it may be unclear which index and hash to use in the ParentBlockIdentifier. It is recommended to use the the geneis BlockIdentifier for both block_identifier and parent_block_identifier.
Error: Negative Block Index
{
"block": {
"block_identifier": {
"index": 0,
"hash": "0x3a065000ab4183C6BF581Dc1E55A605455FC6D61"
},
"parent_block_identifier": {
"index": -1,
"hash": "0x3a065000ab4183C6BF581Dc1E55A605455FC6D61"
},
"timestamp": 1535390993
}
}
Error: No ParentBlockIdentifier
{
"block": {
"block_identifier": {
"index": 0,
"hash": "0x3a065000ab4183C6BF581Dc1E55A605455FC6D61"
},
"timestamp": 1535390993
}
}
Good Example
{
"block": {
"block_identifier": {
"index": 0,
"hash": "0x3a065000ab4183C6BF581Dc1E55A605455FC6D61"
},
"parent_block_identifier": {
"index": 0,
"hash": "0x3a065000ab4183C6BF581Dc1E55A605455FC6D61"
},
"timestamp": 1535390993
}
}
Return Empty Value or Null for Optional Fields
When a field is optional and not populated, it should not be in the returned object. Otherwise, clients could attempt to interpret the returned value.
Error: SubAccountIdentifier Empty Address
{
"account_identifier": {
"address": "0x5be1bfc0b1f01f32178d46abf70bb5ff5c4e425a",
"sub_account": {
"address": ""
}
}
}
Good Example
{
"account_identifier": {
"address": "0x5be1bfc0b1f01f32178d46abf70bb5ff5c4e425a"
}
}
Return Transactions to Fetch in Block Transactions
If transactions must be retrieved using the /block/transaction endpoint, they must be returned in other_transactions. Recall, this endpoint is used when the /block endpoint does not populate all transactions (it is optional).
Bad Example: Populate Transactions
{
"block": {
"block_identifier": {
"index": 0,
"hash": "0xa10ea72d4dfc3f09ff89d8a864069115208e75c77f210900054eecf2626ad610"
},
"parent_block_identifier": {
"index": -1,
"hash": "0xa10ea72d4dfc3f09ff89d8a864069115208e75c77f210900054eecf2626ad610"
},
"timestamp": 1535390993,
"transactions": [
{
"transaction_identifier": {
"hash": "0xa10ea72d4dfc3f09ff89d8a864069115208e75c77f210900054eecf2626ad610"
},
"operations": null
}
]
}
}
Good Example
{
"block": {
"block_identifier": {
"index": 1000,
"hash": "0x445b5c8af787a213f9b0d59c3e2d22a33502d2d030802f1abb4a495f3fc6dad9"
},
"parent_block_identifier": {
"index": 999,
"hash": "0xaa1df7734723058084a7f88b337291a881642d822a5edd7e2ec6c0c8cd029845"
},
"timestamp": 1535390993,
"other_transactions": [
{
"hash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347"
}
]
}
}
Incorrect Transaction Submission Response
Incorrect Status
The /construction/submit endpoint should only return a 200 status if the submitted transaction could be included in the mempool. If a submission could not be included (ex: invalid signature), it should return an error.
Blocking on Submission
Any request to the /construction/submit endpoint should not block on the transaction being included in a block. It should return immediately with an indication of whether or not the transaction was included in the mempool. Handling transaction rebroadcast is a requirement placed on the client.
Unretrievable AccountIdentifier
Any AccountIdentifier returned in a block could be used as an input to an /account/balance request. Ensure your Rosetta Server can gracefully handle any request containing an AccountIdentifier found in a block.