Soroban Snippets: Understanding Assets with Smart Contracts
Tags: soroban, stellar, javascript, web3
Published: 2023-12-04 23:48:15

# 1. Create Stellar Asset

Assets play a fundamental role in Stellar, representing tokens, liquidity pools, or even NFTs that can be both created and transferred. Identification of Stellar Assets is based on an **Asset Code** and the **issuer's public key**. Creating a Stellar Asset is a straightforward process with numerous tutorials available, such as the one provided by the Stellar Development Foundation (SDF) titled [Issue an Asset](https://developers.stellar.org/docs/issuing-assets/how-to-issue-an-asset). In essence, the creation involves two public keys, namely an issuer and a distributor. The procedure includes establishing a trustline before transferring funds and assets to the destination address through a payment operation. The tutorial further introduces the crucial concept of unique asset identification, underscoring the significance of combining asset codes and issuer public keys. By following this guide, you can enhance your comprehension and gain hands-on experience in the creation and management of assets on the Stellar network.

[Create Stellar Asset](https://soroban-snippet.vercel.app/?title=a35eb9ec7dc3a51e56477fdb045592564668702e6ff1d6d8847a4c9a7d29fc20)
# 2. Create Soroban Wrapped Asset

Soroban, a smart contract platform for Stellar, introduces a unique asset management approach by enabling the creation and funding of Stellar Assets that can be wrapped into Soroban tokens. This process incorporates smart contracts, representing wrapped assets similarly to Classic Assets. Additionally, Soroban supports the issuance of tokens as Stellar Assets or as custom Soroban Tokens, providing flexibility in logic implementation. The "Stellar Asset Contract" (SAC) (Like the ERC-20), further enhances interoperability by allowing users to utilize their (classic) Stellar account and trustline balances in Soroban. The `soroban lab token wrap` command facilitates experimentation with wrapping. However in this comprehensive tutorial guides users incoporate the wrapping functionality in their dapps (JS/TS) through HostFunction creation, Operation generation, and the use of Freighter to wrap assets and integrate them into the wallet. 

[Create Soroban Wrapped Asset](https://soroban-snippet.vercel.app/?title=129c27e42b75339d45ba6b15de88a0a6eee41fae01fe4da955ac0032b51cd3ad)

# 3. Get Contract from Wrapped Asset

Once a token is created and wrapped, understanding how to retrieve its information becomes crucial. There are scenarios where assessing the token contract becomes necessary to invoke its methods. This section elaborates on the process of transforming Stellar Assets into Soroban contracts, offering insights into two distinct methods for this conversion. The resulting contract ID, beginning with "C," represents a hashed version of the asset's details. It's important to note that these contract IDs are hypothetical and **may not exist if the asset is not wrapped** or created. In the tutorials, developers have the opportunity to input the asset code and issuer details, exploring and comprehending the process of obtaining Soroban contracts from Wrapped Stellar Assets.

[Get Contract from Wrapped Asset](https://soroban-snippet.vercel.app/?title=40659fceff422b8aa0fedea0f8ad836dcf5189e20b5ae316607227b5c1d75e49)