forked from arein/dapp-smart-account
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ergo namespace (CAIP2, CAIP10, CAIP19) (ethereum#98)
- Loading branch information
Showing
4 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
namespace-identifier: ergo | ||
title: Ergo Ecosystem | ||
author: Yuriy Gagarin (@gagarin55) | ||
discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 | ||
status: Draft | ||
type: Informational | ||
created: 2023-11-02 | ||
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. | ||
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 | ||
|
||
The namespace "ergo" refers to the Ergo open-source blockchain platform. | ||
|
||
## References | ||
|
||
- [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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
namespace-identifier: ergo-caip10 | ||
title: Ergo Namespace - Addresses | ||
author: Yuriy Gagarin (@gagarin55) | ||
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"] | ||
--- | ||
|
||
# CAIP-10 | ||
|
||
*For context, see the [CAIP-10][] specification.* | ||
|
||
## Rationale | ||
|
||
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 identifier + address type discriminant` | ||
- **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 | ||
- **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 | ||
|
||
The syntax of Ergo addresses: | ||
|
||
``` | ||
caip10-like address: namespace + ":" chainId + ":" + address | ||
namespace: ergo | ||
chain Id: 32-character prefix from the hash of the genesis block | ||
address: Ergo address represented as a [Base58btc][]-encoded string | ||
``` | ||
|
||
|
||
|
||
## Test Cases | ||
|
||
``` | ||
# Namespace-wide bare public key in standard expression, without prefixes | ||
# 0x0202f2b96aa59e6f37fc978883f78e54fd319fa37dcf971d8e69f9e9225376bcf1 | ||
# P2PK Address on Ergo Mainnet | ||
ergo:b0244dfc267baca974a4caee06120321:9eYMpbGgBf42bCcnB2nG3wQdqPzpCCw5eB1YaWUUen9uCaW3wwm | ||
# P2PK Address on Ergo Testnet | ||
ergo:e7553c9a716bb3983ac8b0c21689a1f3:3WvdWQMfUeKFcsQudPM4zqTCcncSAtYZgi96Vr3zLJqYQVn2qmaw | ||
``` | ||
|
||
## 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 | ||
[blake2b256]: https://datatracker.ietf.org/doc/html/rfc7693#section-4 | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via | ||
[CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
namespace-identifier: ergo-caip19 | ||
title: Ergo Namespace - Assets | ||
author: Yuriy Gagarin (@gagarin55) | ||
discussions-to: https://github.com/ChainAgnostic/namespaces/pull/98 | ||
status: Draft | ||
type: Standard | ||
created: 2023-11-04 | ||
updated: 2023-12-12 | ||
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 (see [EIP-0004]) 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: 32-character prefix from the hash of the genesis block | ||
reference: Ergo Asset ID represented as hex string | ||
``` | ||
|
||
## Examples | ||
|
||
``` | ||
# Ergo Mainnet | ||
ergo:b0244dfc267baca974a4caee06120321:56d89fdb0c92605d6c80f06a4c6a217f62bdc5695776f916daeabd708683f60d | ||
# Ergo Testnet | ||
ergo:e7553c9a716bb3983ac8b0c21689a1f3:0160b869f30a5424e59cb3453e8a726b81fe83761d02ab41829cb7b2e4b624bc | ||
``` | ||
|
||
## Links | ||
|
||
- [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 | ||
[EIP-0004]: https://github.com/ergoplatform/eips/blob/master/eip-0004.md | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](../LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
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-09 | ||
--- | ||
|
||
|
||
## 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 32-character prefix from the hash of the genesis block of a given chain, in lowercase hex representation. | ||
|
||
|
||
### Syntax | ||
|
||
The `chain_id` is a case-sensitive string in the form | ||
|
||
``` | ||
chain_id: namespace + ":" + reference | ||
namespace: ergo | ||
reference: 32-character prefix from the hash of the genesis block | ||
``` | ||
|
||
### Resolution method | ||
|
||
One can resolve chain ID by request `info` method on Ergo node API (see [RPC Endpoints][]): | ||
``` | ||
curl https://node.ergo.watch/info | ||
``` | ||
|
||
JSON Response contains `genesisBlockId` field: | ||
``` | ||
{ | ||
... | ||
"genesisBlockId" : "b0244dfc267baca974a4caee06120321562784303a8a688976ae56170e4d175b", | ||
... | ||
} | ||
``` | ||
So chain ID for Mainnet is `b0244dfc267baca974a4caee06120321`. | ||
|
||
|
||
## Test Cases | ||
|
||
This is a list of manually composed examples | ||
|
||
``` | ||
# Ergo mainnet | ||
ergo:b0244dfc267baca974a4caee06120321 | ||
# Ergo testnet | ||
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 | ||
|
||
Copyright and related rights waived via [CC0](../LICENSE). |