DEV Community

Peter
Peter

Posted on • Originally published at soroban-snippet.vercel.app

Soroban Snippets: Understanding Assets with Smart Contracts

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. 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

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

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

Top comments (0)