AssetsΒΆ

Object of the Asset class represents an asset in the Stellar network. Right now there are 3 possible types of assets in the Stellar network:

  • native XLM asset (ASSET_TYPE_NATIVE),

  • issued assets with asset code of maximum 4 characters (ASSET_TYPE_CREDIT_ALPHANUM4),

  • issued assets with asset code of maximum 12 characters (ASSET_TYPE_CREDIT_ALPHANUM12).

To create a new native asset representation use static native() method:

1from stellar_sdk import Asset
2native = Asset.native()

To represent an issued asset you need to create a new object of type Asset with an asset code and issuer:

1from stellar_sdk import Asset
2# Creates TEST asset issued by GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB
3test_asset = Asset("TEST", "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB")
4is_native = test_asset.is_native()  # False
5# Creates Google stock asset issued by GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB
6google_stock_asset = Asset('US38259P7069', 'GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB')
7google_stock_asset_type = google_stock_asset.type  # credit_alphanum12