Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add monero namespace #65

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions monero/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
namespace-identifier: monero
title: Monero
author: silverpill (@silverpill)
status: Draft
type: Informational
created: 2023-04-27
requires: ["CAIP-2"]
---

# Namespace for Monero chains

This document defines the applicability of CAIP schemes to the blockchains of the Monero ecosystem.

## Syntax

The namespace "monero" refers to the Monero blockchain, its forks and testnets.

## References

- [Community, End-user, and Developer Onboarding Website][communitysite]

[communitysite]: https://www.getmonero.org/

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
116 changes: 116 additions & 0 deletions monero/caip2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
namespace-identifier: monero-caip2
title: Monero - Chains
author: silverpill (@silverpill)
discussions-to: https://github.com/ChainAgnostic/namespaces/issues/41
status: Draft
type: Informational
created: 2023-04-27
requires: ["CAIP-2"]
---

# CAIP-2

*For context, see the [CAIP-2][] specification.*

## Rationale

CAIP-2 defines a way to identify a blockchain. Monero blockchain, its forks and testnets can be uniquely identified by their genesis blocks.

## Syntax

Monero chain ID is a hash of its genesis block, truncated to the first 32 characters.

### Resolution Mechanics

To obtain the genesis block hash, make a JSON-RPC request to the Monero daemon with method [get_block_header_by_height].

Request:

```json
{
"jsonrpc": "2.0",
"id": "0",
"method": "get_block_header_by_height",
"params": {
"height": 0
}
}
```

Response example (Monero mainnet):

```json
{
"id": "0",
"jsonrpc": "2.0",
"result": {
"block_header": {
"block_size": 80,
"block_weight": 80,
"cumulative_difficulty": 1,
"cumulative_difficulty_top64": 0,
"depth": 2873685,
"difficulty": 1,
"difficulty_top64": 0,
"hash": "418015bb9ae982a1975da7d79277c2705727a56894ba0fb246adaabb1f4632e3",
"height": 0,
"long_term_weight": 80,
"major_version": 1,
"miner_tx_hash": "c88ce9783b4f11190d7b9c17a69c1c52200f9faaee8e98dd07e6811175177139",
"minor_version": 0,
"nonce": 10000,
"num_txes": 0,
"orphan_status": false,
"pow_hash": "",
"prev_hash": "0000000000000000000000000000000000000000000000000000000000000000",
"reward": 17592186044415,
"timestamp": 0,
"wide_cumulative_difficulty": "0x1",
"wide_difficulty": "0x1"
},
"credits": 0,
"status": "OK",
"top_hash": "",
"untrusted": false
}
}
```

## Test Cases

This is a list of manually composed examples:

```
# Monero mainnet
monero:418015bb9ae982a1975da7d79277c270

# Monero stagenet
monero:76ee3cc98646292206cd3e86f74d88b4

# Monero testnet
monero:48ca7cd3c8de5b6a4d53d2861fbdaedc

# Monero Private testnet (special case; see below)

monero:00000000000000000000000000000000
# Wownero mainnet
bumblefudge marked this conversation as resolved.
Show resolved Hide resolved
monero:a3fd635dd5cb55700317783469ba749b
```

## Additional Considerations

Private testnet (also known as **regtest** or **fakechain**) has the same genesis block hash as Monero mainnet.
To avoid conflicts, implementers should use chain ID `monero:00000000000000000000000000000000` to identify this chain, as above, and implementers are advised to take care in disambiguating this special case in their code.

## References

- [Monero Networks][]

[CAIP-2]: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
[get_block_header_by_height]: https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_block_header_by_height
[Monero Networks]: https://monerodocs.org/infrastructure/networks/

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).