DeploySACWithAssetHostFunction class

Deploys a Stellar Asset Contract (SAC) for a specific classic asset.

This host function creates a Stellar Asset Contract that wraps a specific classic Stellar asset (native XLM or issued asset), making it accessible to Soroban smart contracts. The SAC provides a standard token interface for interacting with the classic asset within the smart contract environment.

Stellar Asset Contracts (SAC):

  • Asset Wrapping: Bridges classic assets to Soroban contracts
  • Standard Interface: Implements Soroban token standard
  • Native Support: Can wrap XLM (native asset)
  • Issued Assets: Can wrap any classic issued asset

Asset Types:

  • Native (XLM): Stellar's native cryptocurrency
  • Credit Assets: Issued assets with code and issuer
  • Alphanumeric 4: Asset codes up to 4 characters
  • Alphanumeric 12: Asset codes up to 12 characters

Use Cases:

  • Enable DeFi protocols with classic assets
  • Create DEX contracts using Stellar assets
  • Build lending/borrowing with existing assets
  • Integrate classic liquidity into smart contracts

Example - Deploy SAC for USDC:

// Deploy SAC for a classic USDC asset
var usdcAsset = AssetTypeCreditAlphaNum4(
  "USDC",
  usdcIssuerAccountId
);

var deploySACFunction = DeploySACWithAssetHostFunction(usdcAsset);

var deployOp = InvokeHostFuncOpBuilder(deploySACFunction)
  .setSourceAccount(deployerAccountId)
  .build();

var transaction = TransactionBuilder(deployerAccount)
  .addOperation(deployOp)
  .setSorobanData(footprint)
  .build();

Example - Deploy SAC for Native XLM:

var deploySACFunction = DeploySACWithAssetHostFunction(AssetTypeNative());

var deployOp = InvokeHostFuncOpBuilder(deploySACFunction)
  .setSourceAccount(deployerAccountId)
  .build();

Important Considerations:

  • One SAC per asset (deterministic contract ID)
  • Maintains trustline requirements
  • Standard Soroban token interface
  • Compatible with existing DeFi protocols
  • Gas costs for deployment

See also:

Inheritance

Constructors

DeploySACWithAssetHostFunction(Asset _asset)
Creates a DeploySACWithAssetHostFunction.

Properties

asset Asset
The classic Stellar asset to wrap in a contract.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
toXdr() XdrHostFunction
Converts this host function to its XDR representation.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited