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

to add hedera/readme, /c2, c10, & c19 #16

Merged
merged 7 commits into from
Jan 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
51 changes: 51 additions & 0 deletions hedera/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
namespace-identifier: hedera
title: Hedera Namespace
author: Danno Ferrin (@shemnon)
status: Accepted
type: Informational
created: 2021-11-01
updated: 2022-03-27
replaces: CAIP-75
---

# Namespace for Hedera chains

This namespace encompasses all 4 networks of the Hedera Hashgraph system, which
is centrally governed and currently includes 4 "Networks" that are
heirarchically organized into "Shards", "Realms", and Assets/Addresses.

## Introduction

The prefix `hedera` designates the CAIP-conformant schemata of the Hedera namespace.

## Governance

Note that the 3 CAIPs defined here have also been edited by their author into a
Hedera Improvement Proposal, [HIP-30][], which has been accepted and published
in 2021. Should the latter be superseded in a future HIP, the informational
encoded here may become out of date; in the case of a conflict, consider the
current body of HIPs canonical for Hedera architecture and consider these CAIPs
a "legacy" addressing system for external consumption.

## References

- [HIP-30][]: CAIP Identifiers for the Hedera Network
- [Hedera Developer Documentation](https://docs.hedera.com/guides/)

[CAIP-2]: https://chainAgnostic.org/CAIPS/caip-19
[CAIP-10]: https://chainAgnostic.org/CAIPS/caip-19
[CAIP-19]: https://chainAgnostic.org/CAIPS/caip-19
[CAIP-152]: https://chainAgnostic.org/CAIPS/caip-152
[CAIP-153]: https://chainAgnostic.org/CAIPS/caip-153
[HIP-15]: https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-15.md
[HIP-30]: https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-30.md
[Hedera Developer Documentation]: https://docs.hedera.com/guides/
[Native Account Syntax]: https://docs.hedera.com/guides/core-concepts/accounts#account-id
[Hedera Token Service SDK Docs]: https://docs.hedera.com/guides/docs/sdks/tokens
[ERC20 & ERC721 Compatibility]: https://docs.hedera.com/guides/core-concepts/smart-contracts/supported-erc-token-standards

## Copyright

Copyright and related rights waived
via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).****
108 changes: 108 additions & 0 deletions hedera/caip10.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
namespace-identifier: hedera-caip10
title: Hedera Namespace - Accounts
author: Danno Ferrin (@shemnon)
discussions-to: https://github.com/hashgraph/hedera-improvement-proposal/discussions/169
status: Draft
type: Standard
created: 2021-11-01
updated: 2022-03-27
requires: ["CAIP-2", "CAIP-10"]
replaces: CAIP-75
---

# CAIP-10

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

## Rationale

In CAIP-10, a string-based general account address scheme is defined. The
canonical representation of a Hedera Address encodes a three-part Hedera
account ID as a string by separating the three parts with `.`s; this
future-proofs the implementation of realms and shards, although in today's
usage, effectively all known addresses still begin with `0.0.`.

### Syntax

The `account_id` is a case-sensitive string in the form:

```
account_id: chain_id + ":" + account_address + checksum{0,1}
chain_id: [:-a-zA-Z0-9]{5,32}
account_address: [0-9]{1,19} + "." + [0-9]{1,19} + "." + [0-9]{1,19}
optional checksum: "-" + [a-z]{5}
```

A regular expression for validating the above can be defined as:
```
hedera:[-a-zA-Z0-9]{5,32}:[0-9]{1,19}\.[0-9]{1,19}\.[0-9]{1,19}(\-[a-z]{5}){0,1}
```

### Semantics

The `chain_id` is specified by the [CAIP-2][] which describes the blockchain id.
The `account_address` is the realm, shard, and account id, where each is
separated by a dot (`.`) and each number is a non-negative signed 64-bit
integer. The default value for realm and shard are 0.

The optional checksum is described in
[HIP-15](https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-15.md).
Addresses with or without checksum are both valid, so deduplication or
canonicalization may be required. Note that intermediaries have no duty to
validate the address against its 5-digit checksum.

## Test Cases

This is a list of manually composed examples

```
# Devnet funding account
hedera:devnet:0.0.98

# Mainnet treasury
hedera:mainnet:0.0.2

# Previewnet app properties account
hedera:previewnet:0.0.121

# Mainnet account with checksum
hedera:mainnet:0.0.123-vfmkw

# Largest possible testnet account
hedera:testnet:9223372036854775807.9223372036854775807.9223372036854775807
```

## Backwards Compatibility

Since the checksum is optional, in pathological account numbering scenarios it
may need to be dropped. It is not expected that we will see this event in normal
usage.

## References

- [Hedera Developer Documentation][]
- [Native Account Syntax][]: Explanation of shard + realm prefix usage within
Hedera ecosystem
- [HIP-15][]: Hedera Improvment Proposal for Network Address Checksums
- [HIP-30][]: CAIP Identifiers for the Hedera Network


[CAIP-2]: https://chainAgnostic.org/CAIPS/caip-2
[CAIP-10]: https://chainAgnostic.org/CAIPS/caip-10
[CAIP-19]: https://chainAgnostic.org/CAIPS/caip-19
[HIP-15]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-15.md
[HIP-30]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-30.md
[Hedera Developer Documentation]: https://docs.hedera.com/guides/
[Native Account Syntax]:
https://docs.hedera.com/guides/core-concepts/accounts#account-id
[Hedera Token Service SDK Docs]: https://docs.hedera.com/guides/docs/sdks/tokens
[ERC20 & ERC721 Compatibility]:
https://docs.hedera.com/guides/core-concepts/smart-contracts/supported-erc-token-standards

## Copyright

Copyright and related rights waived
via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).****
148 changes: 148 additions & 0 deletions hedera/caip19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
---
namespace-identifier: hedera-caip19
title: Hedera Namespace - Assets
author: Danno Ferrin (@shemnon), Juan Caballero (@bumblefudge)
discussions-to: https://github.com/hashgraph/hedera-improvement-proposal/discussions/169
status: Draft
type: Standard
created: 2021-11-01
updated: 2022-03-27
requires: ["CAIP-2", "CAIP-19"]
replaces: CAIP-75
---

# CAIP-19

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

This specification defines a [CAIP-19][] scheme for both fungible and
non-fungible tokenized assets in the Hedera ecosystem. The [Hedera Token
Service][] is used in slightly different ways for both. When interacting with
these two types of Hedera token, Solidity contracts can interact with most (but
not all!) functions defined by the ERC20 and ERC721; for a list, see the current
[ERC20 & ERC721 Compatibility][] page in the developer documentation.

Standard NFT Fees, Metadata and other uses of the "memo" field in HTS tokens,
and custom fees are all out of scope and are not encoded in a CAIP-conformant
address; see [HIP-17][], [HIP-10][], and [HIP-18][] respectively.

# Fungible Tokens

In CAIP-19 a general asset identification scheme is defined. This is the
implementation of [CAIP-19][] for `token` in representing fungible tokens, which
are addressed in the same way as accounts are addressed in the [Hedera CAIP-10
specification](caip10.md), i.e., `{shard}.{realm}.{address}`.

## Semantics

### Token Asset Namespace

The asset namespace for fungible tokens in the Hedera Token Service (HTS) is
`token` (case-sensitive).

### Asset Reference Definition

The Asset Reference format is the tokenID in the specific hashgraph (see the
[Hedera CAIP-10 specification](caip10.md) for semantics).

## Syntax

The following regular expression can be used to validate fungible tokens:

```
hedera:[-a-zA-Z0-9]{5,32}\/token:[0-9]{1,19}\.[0-9]{1,19}\.[0-9]{1,19}(\-[a-z]{5}){0,1}
```

### Backwards Compatibility

Not applicable

## Test Cases

This is a list of manually composed examples

```
# Dried Nutm (Dri)
hedera:mainnet/token:0.0.278981
```

# Non-Fungible Tokens

In CAIP-19 a general asset identification scheme is defined. CAIP-153 extended
this sane scheme to include a broader characterset, enabling the
`.`-concatenated shard/realm prefixes before addresses which are standard in
Hedera. This describes the
implementation of [CAIP-19][] for `token` in representing non-fungible tokens, which are
addressed in the same way as accounts are addressed in the [Hedera CAIP-10
specification](caip10.md), i.e., `{shard}.{realm}.{address}`.

## Semantics

### Token Asset Namespace

The asset namespace is called `nft` hosted in the Hedera Token Service (HTS). It
references HTS non-fungible tokens in the `hedera` namespace (see CAIP-75).

#### Asset Reference Definition

The Asset reference format is the tokenID in the specific hashgraph (see the
[Hedera CAIP-10 specification](caip10.md) for semantics).

#### Token ID Definition

The Token ID reference format is the serial number of the specific token.

## Syntax

The following regular expression can be used to validate fungible tokens:

```
hedera:[-a-zA-Z0-9]{5,32}\/nft:[0-9]{1,19}\.[0-9]{1,19}\.[0-9]{1,19}(\-[a-z]{5}){0,1}\/[0-9]{1,19}
```

### Backwards Compatibility

Not applicable

## Test Cases

This is a list of manually composed examples

```
# Edition 12 of 50: First-Generation Hedera Robot VENOM EDITION
hedera:mainnet/nft:0.0.55492/12
```

## Links

- [Hedera Token Service SDK Docs][]
- [ERC20 & ERC721 Compatibility][]: Note the "Not Supported" section for each contract!
- [HIP-10][]: Token Metadata JSON Schema (for referencing from deployed NFT memo fields)
- [HIP-17][]: NFT specification
- [HIP-18][]: Custom Token Fees
- [HIP-30]: CAIP Identifiers for the Hedera Network

[CAIP-2]: https://chainAgnostic.org/CAIPS/caip-2
[CAIP-10]: https://chainAgnostic.org/CAIPS/caip-10
[CAIP-19]: https://chainAgnostic.org/CAIPS/caip-19
[HIP-10]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-10.md
[HIP-15]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-15.md
[HIP-17]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-17.md
[HIP-18]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-18.md
[HIP-30]:
https://github.com/hashgraph/hedera-improvement-proposal/blob/master/HIP/hip-30.md
[Hedera Developer Documentation]: https://docs.hedera.com/guides/
[Native Account Syntax]:
https://docs.hedera.com/guides/core-concepts/accounts#account-id
[Hedera Token Service SDK Docs]: https://docs.hedera.com/guides/docs/sdks/tokens
[ERC20 & ERC721 Compatibility]:
https://docs.hedera.com/guides/core-concepts/smart-contracts/supported-erc-token-standards

## Copyright

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