From 1fdcb9f81e4bd9988fa197129186fd46e97d2927 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Thu, 2 Nov 2023 14:17:16 +0300 Subject: [PATCH 01/18] initial README added --- ergo/README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 ergo/README.md diff --git a/ergo/README.md b/ergo/README.md new file mode 100644 index 0000000000000..cd1b66016e554 --- /dev/null +++ b/ergo/README.md @@ -0,0 +1,28 @@ +--- +namespace-identifier: ergo +title: Ergo Ecosystem +author: Yuriy Gagarin (@gagarin55) +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/... +status: Draft +type: Informational +created: 2023-11-02 +requires: ["CAIP-2",.....] +--- + +# Namespace for Ergo Blockchains + +This document defines the applicability of CAIP schemes to the blockchains of +the Ergo ecosystem. + +## Syntax + +The namespace "ergo" refers to the Ergo open-source blockchain platform. + +## References + +- [Official website](https://ergoplatform.org/) +- [Ergo Documentation](https://docs.ergoplatform.com/) + +## Copyright + +Copyright and related rights waived via CC0. From 4ec143cd46a8464a622bc292043c6fc539018f3b Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Thu, 2 Nov 2023 15:59:41 +0300 Subject: [PATCH 02/18] caip-2 draft --- ergo/caip2.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 ergo/caip2.md diff --git a/ergo/caip2.md b/ergo/caip2.md new file mode 100644 index 0000000000000..9dd3e7840f724 --- /dev/null +++ b/ergo/caip2.md @@ -0,0 +1,69 @@ +--- +caip: 2 +title: Ergo Blockchain ID Specification +author: Yuriy Gagarin (@gagarin55) +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/.. +status: Draft +type: Standard +created: 2023-11-02 +updated: 2023-11-02 +--- + + +## Abstract + +In CAIP-2 a general blockchain identification scheme is defined. This is the +implementation of CAIP-2 for Ergo network. + + +## Specification + +Blockchains in the "ergo" namespace are identified by their chain ID. +Chain ID is 8-bit unsigned integer in decimal representation. + +### Syntax + +The `chain_id` is a case-sensitive string in the form + +``` +chain_id: namespace + ":" + reference +namespace: ergo +reference: 8-bit unsigned integer +``` + +### Resolution method + +## Rationale + +The chain ID is specified as a one-byte unsigned integer. + +For example, the chain ID of Mainnet is 0, for Testnet is 16. + +There may also be other custom networks based on Ergo, but with a different +chain ID. + +Chain ID is used in [Address][] generation. Therefore, addresses from one chain are invalid on another. + +## Test Cases + +This is a list of manually composed examples + +``` +# Ergo mainnet +ergo:0 + +# Ergo testnet +ergo:16 + +``` + +## References +- [Address][] - Address Encoding scheme on Ergo blockchain + +[Address]:https://docs.ergoplatform.com/assets/py/Ergo_Address_Encoding/ + + + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE). \ No newline at end of file From e272066525dd61a51145d4ab342f17522e966df1 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Thu, 2 Nov 2023 17:34:23 +0300 Subject: [PATCH 03/18] caip10 draft added --- ergo/README.md | 2 +- ergo/caip10.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ ergo/caip2.md | 21 ++++++++++++----- 3 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 ergo/caip10.md diff --git a/ergo/README.md b/ergo/README.md index cd1b66016e554..ba8fc4f271bfd 100644 --- a/ergo/README.md +++ b/ergo/README.md @@ -6,7 +6,7 @@ discussions-to: https://github.com/ChainAgnostic/namespaces/pull/... status: Draft type: Informational created: 2023-11-02 -requires: ["CAIP-2",.....] +requires: ["CAIP-2", "CAIP-10"] --- # Namespace for Ergo Blockchains diff --git a/ergo/caip10.md b/ergo/caip10.md new file mode 100644 index 0000000000000..2f0b26643fa86 --- /dev/null +++ b/ergo/caip10.md @@ -0,0 +1,63 @@ +--- +namespace-identifier: ergo-caip10 +title: Ergo Namespace - Addresses +author: Yuriy Gagarin (@gagarin55) +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/... +status: Draft +type: Standard +created: 2023-11-02 +requires: ["CAIP-2", "CAIP-10"] +--- + +# CAIP-10 + +*For context, see the [CAIP-10][] specification.* + +## Rationale + + +Ergo "address" can change depending on chain ID. This prevents unintentional +transfers across Ergo blockchains. + +## Syntax + +The syntax of Ergo addresses: + +``` +caip10-like address: namespace + ":" chainId + ":" + address +namespace: ergo +chain Id: 8-bit unsigned integer in which lower 4 bits are zeros characters in length +address: Ergo address represented as a [Base58btc][]-encoded string +``` + +The underlying form of each Ergo address is ... + +### Resolution method + +... + +## Test Cases + +``` +# Namespace-wide Public Key: +# [TODO] + +# Address on Ergo Mainnet (0) +ergo:0:[TODO] + +# Address on Ergo Testnet (16) +ergo:16:[TODO] +``` + +## Links + +- [About addresses in Ergo Documentation][address format] +- [Conversion between binary and Base58btc representation][base58btc] + +[address format]: https://docs.ergoplatform.com/dev/wallet/address/address_types +[base58btc]: https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart + +## Copyright + +Copyright and related rights waived via +[CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/ergo/caip2.md b/ergo/caip2.md index 9dd3e7840f724..93d4baad252f4 100644 --- a/ergo/caip2.md +++ b/ergo/caip2.md @@ -19,7 +19,16 @@ implementation of CAIP-2 for Ergo network. ## Specification Blockchains in the "ergo" namespace are identified by their chain ID. -Chain ID is 8-bit unsigned integer in decimal representation. + +Chain ID is 8-bit unsigned integer in which lower 4 bits are zeros. + +Possible values: +* Mainnet - 0 (in hex `0x00`) +* Testnet - 16 (in hex `0x10`) +* Testnet2 - 32 (in hex `0x20`) +... +* TestnetN - 240 in (hex `0xF0`) + ### Syntax @@ -28,19 +37,19 @@ The `chain_id` is a case-sensitive string in the form ``` chain_id: namespace + ":" + reference namespace: ergo -reference: 8-bit unsigned integer +reference: 8-bit unsigned integer in which lower 4 bits are zeros ``` ### Resolution method +...TODO... ## Rationale -The chain ID is specified as a one-byte unsigned integer. +The chain ID is specified as a 8-bit in which lower 4 bits are zeros. -For example, the chain ID of Mainnet is 0, for Testnet is 16. +Because of [Address][] encoding scheme there is only $2^4$ possible blockchains in Ergo ecosystem. -There may also be other custom networks based on Ergo, but with a different -chain ID. +So, the chain ID of Mainnet is 0, for Testnet is 16. Chain ID is used in [Address][] generation. Therefore, addresses from one chain are invalid on another. From 8fcae18216a2b761c94a762e4cbcc436395ab568 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Thu, 2 Nov 2023 18:21:09 +0300 Subject: [PATCH 04/18] caip10: address scheme description --- ergo/caip10.md | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index 2f0b26643fa86..089f8354a47bd 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -15,10 +15,28 @@ requires: ["CAIP-2", "CAIP-10"] ## Rationale - Ergo "address" can change depending on chain ID. This prevents unintentional transfers across Ergo blockchains. +Address types are (semantics described below): + +* 0x01 - Pay-to-PublicKey(P2PK) address +* 0x02 - Pay-to-Script-Hash(P2SH) +* 0x03 - Pay-to-Script(P2S) + +Constructing an address: + +- **Prefix byte** = `chain ID + address type` +(for example, P2S script on the testnet starts with 0x13 before Base58) +- **checksum** = `leftmost_4_bytes (blake2b256 (prefix byte || content bytes))` +- **address** = `prefix byte || content bytes || checksum` + +For an address type, we form `content bytes` as follows: + +- **P2PK** - serialized (compressed) public key +- **P2SH** - first 192 bits of the Blake2b256 hash of serialized script bytes +- **P2S** - serialized script + ## Syntax The syntax of Ergo addresses: @@ -26,15 +44,11 @@ The syntax of Ergo addresses: ``` caip10-like address: namespace + ":" chainId + ":" + address namespace: ergo -chain Id: 8-bit unsigned integer in which lower 4 bits are zeros characters in length +chain Id: 8-bit unsigned integer in which lower 4 bits are zeros address: Ergo address represented as a [Base58btc][]-encoded string ``` -The underlying form of each Ergo address is ... - -### Resolution method -... ## Test Cases @@ -42,10 +56,10 @@ The underlying form of each Ergo address is ... # Namespace-wide Public Key: # [TODO] -# Address on Ergo Mainnet (0) +# P2PK Address on Ergo Mainnet (0) ergo:0:[TODO] -# Address on Ergo Testnet (16) +# P2PK Address on Ergo Testnet (16) ergo:16:[TODO] ``` From 3927026b15b328e1dcad50f119592570cb0d36aa Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Sat, 4 Nov 2023 09:51:00 +0300 Subject: [PATCH 05/18] caip19 draft added --- ergo/caip19.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 ergo/caip19.md diff --git a/ergo/caip19.md b/ergo/caip19.md new file mode 100644 index 0000000000000..7c5ff9af8c48a --- /dev/null +++ b/ergo/caip19.md @@ -0,0 +1,63 @@ +--- +namespace-identifier: ergo-caip19 +title: Ergo Namespace - Assets +author: Yuriy Gagarin (@gagarin55) +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/.. +status: Draft +type: Standard +created: 2023-11-04 +requires: ["CAIP-2", "CAIP-19"] +--- + +## Rationale + +Ergo supports custom tokens as first-class citizens as outlined in EIP-0004. + +A transaction can create tokens from thin air in its outputs if the Asset ID matches the ID of the transaction's first input ([box]). Since the box identifier is cryptographically unique, it's impossible to have a second asset with the same identifier. This rule also implies that only one new asset can be created per transaction. + +The ID format for fungible (ERC20-equivalent) and non-fungible (ERC-721 +equivalent) tokens is the same. The process for issuance of either is also the +same. The only difference is that NFTs must have specific values for certain +properties. + +## Specification of Asset ID + +Asset ID is a 32 byte array encoded as a hex string. When +issued, it is equal to the ID of the transaction's first input that issued this +asset. + +## Syntax + +The syntax of Ergo Asset ID: + +``` +address: namespace + ":" chainId + ":" + reference +namespace: ergo +chain ID: 8-bit unsigned integer in which lower 4 bits are zeros +reference: Ergo Asset ID represented as hex string +``` + +## Examples + +``` +# Ergo Mainnet (0) +ergo:0:56d89fdb0c92605d6c80f06a4c6a217f62bdc5695776f916daeabd708683f60d + +# Ergo Testnet (16) +ergo:16:0160b869f30a5424e59cb3453e8a726b81fe83761d02ab41829cb7b2e4b624bc + +``` + +## Links + +- [Token][token] overview +- [Ergo Box][box] overview +- [About addresses in Ergo Documentation][address format] + +[box]: https://docs.ergoplatform.com/dev/data-model/box/ +[token]: https://docs.ergoplatform.com/dev/data-model/box/tokens/ +[address format]: https://docs.ergoplatform.com/dev/wallet/address/address_types + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE). From 3275f1210d950d961c317ec59106dd4759d53af5 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Tue, 7 Nov 2023 05:43:04 +0300 Subject: [PATCH 06/18] caip19: addresses examples added --- ergo/caip10.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index 089f8354a47bd..6f253c3467b87 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -54,13 +54,13 @@ address: Ergo address represented as a [Base58btc][]-encoded stri ``` # Namespace-wide Public Key: -# [TODO] +# 0x0202f2b96aa59e6f37fc978883f78e54fd319fa37dcf971d8e69f9e9225376bcf1 # P2PK Address on Ergo Mainnet (0) -ergo:0:[TODO] +ergo:0:9eYMpbGgBf42bCcnB2nG3wQdqPzpCCw5eB1YaWUUen9uCaW3wwm # P2PK Address on Ergo Testnet (16) -ergo:16:[TODO] +ergo:16:3WvdWQMfUeKFcsQudPM4zqTCcncSAtYZgi96Vr3zLJqYQVn2qmaw ``` ## Links From 6e5efdacf184618110a79adce45229c741730b41 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Tue, 7 Nov 2023 05:52:45 +0300 Subject: [PATCH 07/18] discussions-to updated --- ergo/caip10.md | 2 +- ergo/caip19.md | 2 +- ergo/caip2.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index 6f253c3467b87..01fffd241f7a7 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -2,7 +2,7 @@ namespace-identifier: ergo-caip10 title: Ergo Namespace - Addresses author: Yuriy Gagarin (@gagarin55) -discussions-to: https://github.com/ChainAgnostic/namespaces/pull/... +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-02 diff --git a/ergo/caip19.md b/ergo/caip19.md index 7c5ff9af8c48a..09e2a45c8cbba 100644 --- a/ergo/caip19.md +++ b/ergo/caip19.md @@ -2,7 +2,7 @@ namespace-identifier: ergo-caip19 title: Ergo Namespace - Assets author: Yuriy Gagarin (@gagarin55) -discussions-to: https://github.com/ChainAgnostic/namespaces/pull/.. +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-04 diff --git a/ergo/caip2.md b/ergo/caip2.md index 93d4baad252f4..6c383fbd3dc8e 100644 --- a/ergo/caip2.md +++ b/ergo/caip2.md @@ -2,7 +2,7 @@ caip: 2 title: Ergo Blockchain ID Specification author: Yuriy Gagarin (@gagarin55) -discussions-to: https://github.com/ChainAgnostic/namespaces/pull/.. +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-02 From d3691c568dbf5021d2b3a985670ba8a42b656cf1 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Tue, 7 Nov 2023 05:56:53 +0300 Subject: [PATCH 08/18] caip2 chain id resolution --- ergo/caip2.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ergo/caip2.md b/ergo/caip2.md index 6c383fbd3dc8e..b9b5afbd1d70f 100644 --- a/ergo/caip2.md +++ b/ergo/caip2.md @@ -41,7 +41,8 @@ reference: 8-bit unsigned integer in which lower 4 bits are zeros ``` ### Resolution method -...TODO... + +One can resolve chain ID decoding Ergo [Address]. ## Rationale From fb15142e6f67b1bedfb1d21bb4e0024d3fa727e7 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Tue, 7 Nov 2023 06:00:23 +0300 Subject: [PATCH 09/18] README: discussions-to updated --- ergo/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ergo/README.md b/ergo/README.md index ba8fc4f271bfd..902f99f81d8b9 100644 --- a/ergo/README.md +++ b/ergo/README.md @@ -2,11 +2,11 @@ namespace-identifier: ergo title: Ergo Ecosystem author: Yuriy Gagarin (@gagarin55) -discussions-to: https://github.com/ChainAgnostic/namespaces/pull/... +discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Informational created: 2023-11-02 -requires: ["CAIP-2", "CAIP-10"] +requires: ["CAIP-2", "CAIP-10", "CAIP-19"] --- # Namespace for Ergo Blockchains From 178221d2a841b368d4f6bfd96d7a09ffbeb5cf07 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Thu, 9 Nov 2023 08:01:52 +0300 Subject: [PATCH 10/18] chain ID is a part of genesis hash --- ergo/caip10.md | 33 +++++++++++++++++++++------------ ergo/caip19.md | 16 +++++++++------- ergo/caip2.md | 44 +++++++++++++++++++++----------------------- 3 files changed, 51 insertions(+), 42 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index 01fffd241f7a7..d3d99883b5988 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -6,6 +6,7 @@ discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-02 +updated: 2023-11-09 requires: ["CAIP-2", "CAIP-10"] --- @@ -15,22 +16,30 @@ requires: ["CAIP-2", "CAIP-10"] ## Rationale -Ergo "address" can change depending on chain ID. This prevents unintentional +Ergo "address" can change depending on Network type. This prevents unintentional transfers across Ergo blockchains. -Address types are (semantics described below): - -* 0x01 - Pay-to-PublicKey(P2PK) address -* 0x02 - Pay-to-Script-Hash(P2SH) -* 0x03 - Pay-to-Script(P2S) Constructing an address: -- **Prefix byte** = `chain ID + address type` +- **Prefix byte** = `network type + address type` (for example, P2S script on the testnet starts with 0x13 before Base58) - **checksum** = `leftmost_4_bytes (blake2b256 (prefix byte || content bytes))` - **address** = `prefix byte || content bytes || checksum` +Network type is 8-bit unsigned integer in which lower 4 bits are zeros. + +Possible values: +* Mainnet - 0 (in hex `0x00`) +* Testnet - 16 (in hex `0x10`) + + +Address types are (semantics described below): + +* 0x01 - Pay-to-PublicKey(P2PK) address +* 0x02 - Pay-to-Script-Hash(P2SH) +* 0x03 - Pay-to-Script(P2S) + For an address type, we form `content bytes` as follows: - **P2PK** - serialized (compressed) public key @@ -44,7 +53,7 @@ The syntax of Ergo addresses: ``` caip10-like address: namespace + ":" chainId + ":" + address namespace: ergo -chain Id: 8-bit unsigned integer in which lower 4 bits are zeros +chain Id: 32-character prefix from the hash of the genesis block address: Ergo address represented as a [Base58btc][]-encoded string ``` @@ -56,11 +65,11 @@ address: Ergo address represented as a [Base58btc][]-encoded stri # Namespace-wide Public Key: # 0x0202f2b96aa59e6f37fc978883f78e54fd319fa37dcf971d8e69f9e9225376bcf1 -# P2PK Address on Ergo Mainnet (0) -ergo:0:9eYMpbGgBf42bCcnB2nG3wQdqPzpCCw5eB1YaWUUen9uCaW3wwm +# P2PK Address on Ergo Mainnet +ergo:b0244dfc267baca974a4caee06120321:9eYMpbGgBf42bCcnB2nG3wQdqPzpCCw5eB1YaWUUen9uCaW3wwm -# P2PK Address on Ergo Testnet (16) -ergo:16:3WvdWQMfUeKFcsQudPM4zqTCcncSAtYZgi96Vr3zLJqYQVn2qmaw +# P2PK Address on Ergo Testnet +ergo:e7553c9a716bb3983ac8b0c21689a1f3:3WvdWQMfUeKFcsQudPM4zqTCcncSAtYZgi96Vr3zLJqYQVn2qmaw ``` ## Links diff --git a/ergo/caip19.md b/ergo/caip19.md index 09e2a45c8cbba..35ba926942421 100644 --- a/ergo/caip19.md +++ b/ergo/caip19.md @@ -1,17 +1,18 @@ --- namespace-identifier: ergo-caip19 title: Ergo Namespace - Assets -author: Yuriy Gagarin (@gagarin55) +author: Yuriy Gagarin (@gagarin55) discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-04 +updated: 2023-11-09 requires: ["CAIP-2", "CAIP-19"] --- ## Rationale -Ergo supports custom tokens as first-class citizens as outlined in EIP-0004. +Ergo supports custom tokens as first-class citizens as outlined in [EIP-0004]. A transaction can create tokens from thin air in its outputs if the Asset ID matches the ID of the transaction's first input ([box]). Since the box identifier is cryptographically unique, it's impossible to have a second asset with the same identifier. This rule also implies that only one new asset can be created per transaction. @@ -33,18 +34,18 @@ The syntax of Ergo Asset ID: ``` address: namespace + ":" chainId + ":" + reference namespace: ergo -chain ID: 8-bit unsigned integer in which lower 4 bits are zeros +chain ID: 32-character prefix from the hash of the genesis block reference: Ergo Asset ID represented as hex string ``` ## Examples ``` -# Ergo Mainnet (0) -ergo:0:56d89fdb0c92605d6c80f06a4c6a217f62bdc5695776f916daeabd708683f60d +# Ergo Mainnet +ergo:b0244dfc267baca974a4caee06120321:56d89fdb0c92605d6c80f06a4c6a217f62bdc5695776f916daeabd708683f60d -# Ergo Testnet (16) -ergo:16:0160b869f30a5424e59cb3453e8a726b81fe83761d02ab41829cb7b2e4b624bc +# Ergo Testnet +ergo:e7553c9a716bb3983ac8b0c21689a1f3:0160b869f30a5424e59cb3453e8a726b81fe83761d02ab41829cb7b2e4b624bc ``` @@ -57,6 +58,7 @@ ergo:16:0160b869f30a5424e59cb3453e8a726b81fe83761d02ab41829cb7b2e4b624bc [box]: https://docs.ergoplatform.com/dev/data-model/box/ [token]: https://docs.ergoplatform.com/dev/data-model/box/tokens/ [address format]: https://docs.ergoplatform.com/dev/wallet/address/address_types +[EIP-0004]: https://github.com/ergoplatform/eips/blob/master/eip-0004.md ## Copyright diff --git a/ergo/caip2.md b/ergo/caip2.md index b9b5afbd1d70f..62658b8dcb3bf 100644 --- a/ergo/caip2.md +++ b/ergo/caip2.md @@ -1,12 +1,12 @@ --- -caip: 2 +namespace-identifier: ergo-caip2 title: Ergo Blockchain ID Specification author: Yuriy Gagarin (@gagarin55) discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-02 -updated: 2023-11-02 +updated: 2023-11-09 --- @@ -20,14 +20,7 @@ implementation of CAIP-2 for Ergo network. Blockchains in the "ergo" namespace are identified by their chain ID. -Chain ID is 8-bit unsigned integer in which lower 4 bits are zeros. - -Possible values: -* Mainnet - 0 (in hex `0x00`) -* Testnet - 16 (in hex `0x10`) -* Testnet2 - 32 (in hex `0x20`) -... -* TestnetN - 240 in (hex `0xF0`) +Chain ID is 32-character prefix from the hash of the genesis block of a given chain, in lowercase hex representation. ### Syntax @@ -37,22 +30,26 @@ The `chain_id` is a case-sensitive string in the form ``` chain_id: namespace + ":" + reference namespace: ergo -reference: 8-bit unsigned integer in which lower 4 bits are zeros +reference: 32-character prefix from the hash of the genesis block ``` ### Resolution method -One can resolve chain ID decoding Ergo [Address]. - -## Rationale - -The chain ID is specified as a 8-bit in which lower 4 bits are zeros. - -Because of [Address][] encoding scheme there is only $2^4$ possible blockchains in Ergo ecosystem. +One can resolve chain ID by request `info` method on Ergo node API (see [RPC Endpoints][]): +``` +curl https://node.ergo.watch/info +``` -So, the chain ID of Mainnet is 0, for Testnet is 16. +JSON Response contains `genesisBlockId` field: +``` +{ +... + "genesisBlockId" : "b0244dfc267baca974a4caee06120321562784303a8a688976ae56170e4d175b", +... +} +``` +So chain ID for Mainnet is `b0244dfc267baca974a4caee06120321`. -Chain ID is used in [Address][] generation. Therefore, addresses from one chain are invalid on another. ## Test Cases @@ -60,18 +57,19 @@ This is a list of manually composed examples ``` # Ergo mainnet -ergo:0 +ergo:b0244dfc267baca974a4caee06120321 # Ergo testnet -ergo:16 +ergo:e7553c9a716bb3983ac8b0c21689a1f3 ``` ## References - [Address][] - Address Encoding scheme on Ergo blockchain +- [RPC Endpoints][] - Ergo full node RPC API [Address]:https://docs.ergoplatform.com/assets/py/Ergo_Address_Encoding/ - +[RPC Endpoints]:https://docs.ergoplatform.com/node/swagger/ ## Copyright From 46164064ac25844ab53f49c872ffd4a2e82844b8 Mon Sep 17 00:00:00 2001 From: Bumblefudge Date: Thu, 23 Nov 2023 13:19:30 +0100 Subject: [PATCH 11/18] apply new style guide for line breaks --- ergo/caip10.md | 5 ++--- ergo/caip19.md | 16 ++++++++-------- ergo/caip2.md | 5 ++--- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index d3d99883b5988..230d6f0c64d1d 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -16,9 +16,8 @@ requires: ["CAIP-2", "CAIP-10"] ## Rationale -Ergo "address" can change depending on Network type. This prevents unintentional -transfers across Ergo blockchains. - +Ergo "address" can change depending on Network type. +This prevents unintentional transfers across Ergo blockchains. Constructing an address: diff --git a/ergo/caip19.md b/ergo/caip19.md index 35ba926942421..0a469bb3749d4 100644 --- a/ergo/caip19.md +++ b/ergo/caip19.md @@ -14,18 +14,18 @@ requires: ["CAIP-2", "CAIP-19"] Ergo supports custom tokens as first-class citizens as outlined in [EIP-0004]. -A transaction can create tokens from thin air in its outputs if the Asset ID matches the ID of the transaction's first input ([box]). Since the box identifier is cryptographically unique, it's impossible to have a second asset with the same identifier. This rule also implies that only one new asset can be created per transaction. +A transaction can create tokens from thin air in its outputs if the Asset ID matches the ID of the transaction's first input ([box]). +Since the box identifier is cryptographically unique, it's impossible to have a second asset with the same identifier. +This rule also implies that only one new asset can be created per transaction. -The ID format for fungible (ERC20-equivalent) and non-fungible (ERC-721 -equivalent) tokens is the same. The process for issuance of either is also the -same. The only difference is that NFTs must have specific values for certain -properties. +The ID format for fungible (ERC20-equivalent) and non-fungible (ERC-721 equivalent) tokens is the same. +The process for issuance of either is also the same. +The only difference is that NFTs must have specific values for certain properties. ## Specification of Asset ID -Asset ID is a 32 byte array encoded as a hex string. When -issued, it is equal to the ID of the transaction's first input that issued this -asset. +Asset ID is a 32 byte array encoded as a hex string. +When issued, it is equal to the ID of the transaction's first input that issued this asset. ## Syntax diff --git a/ergo/caip2.md b/ergo/caip2.md index 62658b8dcb3bf..796d8e2c0a3ce 100644 --- a/ergo/caip2.md +++ b/ergo/caip2.md @@ -12,9 +12,8 @@ updated: 2023-11-09 ## Abstract -In CAIP-2 a general blockchain identification scheme is defined. This is the -implementation of CAIP-2 for Ergo network. - +In CAIP-2 a general blockchain identification scheme is defined. +This is the implementation of CAIP-2 for Ergo network. ## Specification From 134d4e68fd2b54b0d3c22fe83316964f42323582 Mon Sep 17 00:00:00 2001 From: Bumblefudge Date: Thu, 23 Nov 2023 13:39:53 +0100 Subject: [PATCH 12/18] editorial suggestions on CAIP-10 to aid clarity --- ergo/caip10.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index 230d6f0c64d1d..559f9c0ecb819 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -16,13 +16,13 @@ requires: ["CAIP-2", "CAIP-10"] ## Rationale -Ergo "address" can change depending on Network type. +A given Ergo "address" changes completely depending on the network identifier segment. +Different address types in the Ergo-specific UTXO model, like the network identifier used to encode the network on which the address can be dereferenced, can only be determined by decoding the string and inspecting the initial prefix byte. This prevents unintentional transfers across Ergo blockchains. Constructing an address: -- **Prefix byte** = `network type + address type` -(for example, P2S script on the testnet starts with 0x13 before Base58) +- **Prefix byte** = `network identifier + address type discriminant` - **checksum** = `leftmost_4_bytes (blake2b256 (prefix byte || content bytes))` - **address** = `prefix byte || content bytes || checksum` @@ -45,6 +45,8 @@ For an address type, we form `content bytes` as follows: - **P2SH** - first 192 bits of the Blake2b256 hash of serialized script bytes - **P2S** - serialized script +The checksum is calculated after concatenating prefix byte to content bytes, and then postpended to form a full Ergo standard address notation. + ## Syntax The syntax of Ergo addresses: From f2c0dc092f262b5710dd71473c7d09daa6fde53e Mon Sep 17 00:00:00 2001 From: Bumblefudge Date: Thu, 23 Nov 2023 13:43:05 +0100 Subject: [PATCH 13/18] editorial suggestions on readme to mention utxo/box nuance upfront --- ergo/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ergo/README.md b/ergo/README.md index 902f99f81d8b9..62a60c1d1116e 100644 --- a/ergo/README.md +++ b/ergo/README.md @@ -12,7 +12,8 @@ requires: ["CAIP-2", "CAIP-10", "CAIP-19"] # Namespace for Ergo Blockchains This document defines the applicability of CAIP schemes to the blockchains of -the Ergo ecosystem. +the Ergo ecosystem. +Ergo uses a variant of the UTXO addressing model that introduces an abstraction called a [box], which can be helpful to understand before attempting interoperability with either account-model or classic UTXO namespaces. ## Syntax @@ -23,6 +24,8 @@ The namespace "ergo" refers to the Ergo open-source blockchain platform. - [Official website](https://ergoplatform.org/) - [Ergo Documentation](https://docs.ergoplatform.com/) +[box]: https://docs.ergoplatform.com/dev/data-model/box/ + ## Copyright Copyright and related rights waived via CC0. From 4690aa9a0a24d3d14bc5c0a40b8791eb886ffa9d Mon Sep 17 00:00:00 2001 From: Yuri Gagarin Date: Tue, 12 Dec 2023 15:02:53 +0300 Subject: [PATCH 14/18] Update ergo/caip10.md Co-authored-by: Bumblefudge --- ergo/caip10.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ergo/caip10.md b/ergo/caip10.md index 559f9c0ecb819..c0defa2dc15a7 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -80,6 +80,7 @@ ergo:e7553c9a716bb3983ac8b0c21689a1f3:3WvdWQMfUeKFcsQudPM4zqTCcncSAtYZgi96Vr3zLJ [address format]: https://docs.ergoplatform.com/dev/wallet/address/address_types [base58btc]: https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart +[blake2b256]: https://datatracker.ietf.org/doc/html/rfc7693#section-4 ## Copyright From aee083f7024eb2e0187dbea6f557aa68091cb4d6 Mon Sep 17 00:00:00 2001 From: Yuri Gagarin Date: Tue, 12 Dec 2023 15:03:21 +0300 Subject: [PATCH 15/18] Update ergo/caip10.md Co-authored-by: Bumblefudge --- ergo/caip10.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index c0defa2dc15a7..f272391b30def 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -42,7 +42,7 @@ Address types are (semantics described below): For an address type, we form `content bytes` as follows: - **P2PK** - serialized (compressed) public key -- **P2SH** - first 192 bits of the Blake2b256 hash of serialized script bytes +- **P2SH** - first 192 bits of the [Blake2b256][] hash of serialized script bytes - **P2S** - serialized script The checksum is calculated after concatenating prefix byte to content bytes, and then postpended to form a full Ergo standard address notation. From 8d9a8a0d58253a10c7ad6f9b19b2780abdb05c43 Mon Sep 17 00:00:00 2001 From: Yuri Gagarin Date: Tue, 12 Dec 2023 15:04:20 +0300 Subject: [PATCH 16/18] Update ergo/caip10.md Co-authored-by: Bumblefudge --- ergo/caip10.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index f272391b30def..db55d670a6fd6 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -63,7 +63,7 @@ address: Ergo address represented as a [Base58btc][]-encoded stri ## Test Cases ``` -# Namespace-wide Public Key: +# Namespace-wide bare public key in standard expression, without prefixes # 0x0202f2b96aa59e6f37fc978883f78e54fd319fa37dcf971d8e69f9e9225376bcf1 # P2PK Address on Ergo Mainnet From 05cbd73d5e5580f8d2094001fcea2c62aa2428bf Mon Sep 17 00:00:00 2001 From: Yuri Gagarin Date: Tue, 12 Dec 2023 15:16:56 +0300 Subject: [PATCH 17/18] Update ergo/caip10.md Co-authored-by: Bumblefudge --- ergo/caip10.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ergo/caip10.md b/ergo/caip10.md index db55d670a6fd6..389b62cde1036 100644 --- a/ergo/caip10.md +++ b/ergo/caip10.md @@ -44,7 +44,7 @@ For an address type, we form `content bytes` as follows: - **P2PK** - serialized (compressed) public key - **P2SH** - first 192 bits of the [Blake2b256][] hash of serialized script bytes - **P2S** - serialized script - +One the above has been constructed in binary, it is encoded according to the [Base58btc][] alphabet to be expressed as the `address` segment of a CAIP-10 string. The checksum is calculated after concatenating prefix byte to content bytes, and then postpended to form a full Ergo standard address notation. ## Syntax From 77e70fa54e42eb6b2575de270ebdd83308d87fb4 Mon Sep 17 00:00:00 2001 From: gagarin55 Date: Tue, 12 Dec 2023 16:19:18 +0300 Subject: [PATCH 18/18] minor improvement in CAIP-19 --- ergo/caip19.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ergo/caip19.md b/ergo/caip19.md index 0a469bb3749d4..feae12cb53a9a 100644 --- a/ergo/caip19.md +++ b/ergo/caip19.md @@ -6,7 +6,7 @@ discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 status: Draft type: Standard created: 2023-11-04 -updated: 2023-11-09 +updated: 2023-12-12 requires: ["CAIP-2", "CAIP-19"] --- @@ -20,7 +20,7 @@ This rule also implies that only one new asset can be created per transaction. The ID format for fungible (ERC20-equivalent) and non-fungible (ERC-721 equivalent) tokens is the same. The process for issuance of either is also the same. -The only difference is that NFTs must have specific values for certain properties. +The only difference is that NFTs must have specific values (see [EIP-0004]) for certain properties. ## Specification of Asset ID @@ -54,7 +54,7 @@ ergo:e7553c9a716bb3983ac8b0c21689a1f3:0160b869f30a5424e59cb3453e8a726b81fe83761d - [Token][token] overview - [Ergo Box][box] overview - [About addresses in Ergo Documentation][address format] - +- [Ergo Assets standard][EIP-0004] [box]: https://docs.ergoplatform.com/dev/data-model/box/ [token]: https://docs.ergoplatform.com/dev/data-model/box/tokens/ [address format]: https://docs.ergoplatform.com/dev/wallet/address/address_types