diff --git a/docs/fundamentals-and-concepts/stellar-data-structures/assets.mdx b/docs/fundamentals-and-concepts/stellar-data-structures/assets.mdx index fee839a25..a289ad557 100644 --- a/docs/fundamentals-and-concepts/stellar-data-structures/assets.mdx +++ b/docs/fundamentals-and-concepts/stellar-data-structures/assets.mdx @@ -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. @@ -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 + + +```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") +``` + + + +## 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. diff --git a/docusaurus.config.js b/docusaurus.config.js index 027bd3277..2ce77e57b 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -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"], }, }), };