Skip to content

Commit

Permalink
Added code blocks (#10)
Browse files Browse the repository at this point in the history
* Added code blocks

Please look at why it won't tab out the code blocks!

* added json5 and missing python library

Co-authored-by: Tyler van der Hoeven <[email protected]>
  • Loading branch information
briwylde08 and kalepail authored Aug 30, 2022
1 parent f06b31f commit da490e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
38 changes: 34 additions & 4 deletions docs/fundamentals-and-concepts/stellar-data-structures/assets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ title: Assets
sidebar_position: 30
---

import { CodeExample } from "@site/src/components/CodeExample"

Accounts on the Stellar network can be used to track, hold, and transfer any type of asset. Assets can represent many things: cryptocurrencies (such as bitcoin or ether), fiat currencies (such as dollars or pesos), other tokens of value (such as NFTs), pool shares, or even bonds and equity.

Assets on Stellar have two identifying characteristics: the asset code and the issuer. Since more than one organization can issue a credit representing the same asset, asset codes often overlap (for example, multiple companies offer a USD token on Stellar). Assets are uniquely identified by the combination of their asset code and issuer.
Expand All @@ -26,13 +28,41 @@ The public key of the issuing account is linked on the ledger to the asset. Resp
## Representation
In Horizon, assets are represented in a JSON object:

[insert code]
```json5
{
"asset_code": "AstroDollar",
"asset_issuer": "GC2BKLYOOYPDEFJKLKY6FNNRQMGFLVHJKQRGNSSRRGSMPGF32LHCQVGF",
// `asset_type` is used to determine how asset data is stored.
// It can be `native` (lumens), `credit_alphanum4`, or `credit_alphanum12`.
"asset_type": "credit_alphanum12"
}
```

In the Stellar SDKs, they’re represented with the asset class:

[insert code]

## Amount Precision
<CodeExample>

```js
var astroDollar = new StellarSdk.Asset(
"AstroDollar",
"GC2BKLYOOYPDEFJKLKY6FNNRQMGFLVHJKQRGNSSRRGSMPGF32LHCQVGF",
);
```

```java
KeyPair issuer = KeyPair.fromAccountId("GC2BKLYOOYPDEFJKLKY6FNNRQMGFLVHJKQRGNSSRRGSMPGF32LHCQVGF");
Asset astroDollar = Asset.createNonNativeAsset("AstroDollar", issuer.getAccountId());
```

```python
from stellar_sdk import Asset

astro_dollar = Asset("AstroDollar", "GC2BKLYOOYPDEFJKLKY6FNNRQMGFLVHJKQRGNSSRRGSMPGF32LHCQVGF")
```

</CodeExample>

## Amount precision
Each asset amount is encoded as a signed 64-bit integer in the XDR structures that Stellar uses to encode transactions. The asset amount unit seen by end-users is scaled down by a factor of ten million (10,000,000) to arrive at the native 64-bit integer representation.

For example, the integer amount value 25,123,456 equals 2.5123456 units of the asset. This scaling allows for seven decimal places of precision in human-friendly amount units.
Expand Down
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const config = {
prism: {
theme: require('prism-react-renderer/themes/github'),
darkTheme: require('prism-react-renderer/themes/vsDark'),
additionalLanguages: ["java", "rust", "toml"],
additionalLanguages: ["java", "rust", "toml", "json5", "python"],
},
}),
};
Expand Down

0 comments on commit da490e7

Please sign in to comment.