RegulatedAsset
extends AssetTypeCreditAlphanum
in package
Represents a regulated asset that requires issuer approval for transactions.
Regulated assets implement transaction-level compliance by requiring the asset issuer to approve each transaction before it can be submitted to the Stellar network. This enables issuers to maintain regulatory compliance for securities, regulated financial instruments, and other assets subject to jurisdictional requirements.
Per SEP-0008 specification, regulated asset issuers must have both Authorization Required and Authorization Revocable flags set on their account. This allows the issuer to grant and revoke authorization to transact the asset, which is essential for the per-transaction approval workflow.
The approval workflow:
- Wallet builds and signs transaction with user's private key
- Wallet submits transaction to approval server (not to Stellar network)
- Approval server evaluates transaction against compliance criteria
- Server responds with approval (signed transaction) or rejection
- If approved, wallet submits signed transaction to Stellar network
This class extends AssetTypeCreditAlphanum to include approval server information and criteria required for the regulated assets compliance workflow.
Tags
Table of Contents
Constants
- TYPE_CREDIT_ALPHANUM_12 = "credit_alphanum12"
- TYPE_CREDIT_ALPHANUM_4 = "credit_alphanum4"
- TYPE_NATIVE = "native"
- TYPE_POOL_SHARE = "liquidty_pool_shares"
Properties
- $approvalCriteria : string|null
- $approvalServer : string
- $code : string
- $issuer : string
Methods
- __construct() : mixed
- Constructor
- canonicalForm() : string
- Returns the canonical string representation of an asset
- create() : Asset
- Creates an asset from its type, code, and issuer
- createFromCanonicalForm() : Asset|null
- Creates an asset from its canonical string representation
- createNonNativeAsset() : AssetTypeCreditAlphanum
- Creates a non-native asset with automatic type detection based on code length
- fromJson() : Asset
- Creates an asset from JSON data (typically from Horizon responses)
- fromXdr() : Asset
- Creates an Asset from its XDR representation
- getCode() : string
- Returns the asset code
- getIssuer() : string
- Returns the issuer account ID
- getType() : string
- Returns the asset type (credit_alphanum4 or credit_alphanum12).
- native() : AssetTypeNative
- Creates the native XLM asset
- setCode() : void
- Sets the asset code
- setIssuer() : void
- Sets the issuer account ID
- toXdr() : XdrAsset
- Converts the asset to its XDR representation.
- toXdrChangeTrustAsset() : XdrChangeTrustAsset
- Converts this asset to XDR ChangeTrustAsset format
- toXdrTrustlineAsset() : XdrTrustlineAsset
- Converts this asset to XDR TrustlineAsset format
Constants
TYPE_CREDIT_ALPHANUM_12
public
mixed
TYPE_CREDIT_ALPHANUM_12
= "credit_alphanum12"
TYPE_CREDIT_ALPHANUM_4
public
mixed
TYPE_CREDIT_ALPHANUM_4
= "credit_alphanum4"
TYPE_NATIVE
public
mixed
TYPE_NATIVE
= "native"
TYPE_POOL_SHARE
public
mixed
TYPE_POOL_SHARE
= "liquidty_pool_shares"
Properties
$approvalCriteria
public
string|null
$approvalCriteria
= null
$approvalServer
public
string
$approvalServer
$code
protected
string
$code
$issuer
protected
string
$issuer
Methods
__construct()
Constructor
public
__construct(string $code, string $issuer, string $approvalServer[, string|null $approvalCriteria = null ]) : mixed
Parameters
- $code : string
-
asset code
- $issuer : string
-
asset issuer
- $approvalServer : string
-
approval server
- $approvalCriteria : string|null = null
-
approval criteria
canonicalForm()
Returns the canonical string representation of an asset
public
static canonicalForm(Asset $asset) : string
Format:
- Native: "native"
- Issued: "CODE:ISSUER" (e.g., "USD:GABC...")
Parameters
- $asset : Asset
-
The asset to convert
Tags
Return values
string —The canonical form
create()
Creates an asset from its type, code, and issuer
public
static create(string $type[, string|null $code = null ][, string|null $issuer = null ]) : Asset
Parameters
- $type : string
-
One of the TYPE_* constants
- $code : string|null = null
-
Asset code (required for non-native assets)
- $issuer : string|null = null
-
Issuer account ID (required for non-native assets)
Tags
Return values
Asset —The created asset
createFromCanonicalForm()
Creates an asset from its canonical string representation
public
static createFromCanonicalForm(string $canonicalForm) : Asset|null
Accepted formats:
- "native" or "XLM" for native XLM
- "CODE:ISSUER" for issued assets (e.g., "USD:GABC...")
Parameters
- $canonicalForm : string
-
The canonical asset string
Return values
Asset|null —The created asset, or null if the format is invalid
createNonNativeAsset()
Creates a non-native asset with automatic type detection based on code length
public
static createNonNativeAsset(string $code, string $issuer) : AssetTypeCreditAlphanum
The asset type (AlphaNum4 or AlphaNum12) is determined automatically based on the length of the asset code.
Parameters
- $code : string
-
Asset code (1-12 characters)
- $issuer : string
-
Issuer account ID (public key starting with G)
Tags
Return values
AssetTypeCreditAlphanum —The created asset (AlphaNum4 or AlphaNum12)
fromJson()
Creates an asset from JSON data (typically from Horizon responses)
public
static fromJson(array<string|int, mixed> $json) : Asset
Parameters
- $json : array<string|int, mixed>
-
JSON data with asset_type, asset_code, and asset_issuer fields
Return values
Asset —The created asset
fromXdr()
Creates an Asset from its XDR representation
public
static fromXdr(XdrAsset $xdrAsset) : Asset
Parameters
- $xdrAsset : XdrAsset
-
The XDR asset data
Tags
Return values
Asset —The reconstructed asset
getCode()
Returns the asset code
public
getCode() : string
Return values
string —The asset code (e.g., "USD", "BTC")
getIssuer()
Returns the issuer account ID
public
getIssuer() : string
Return values
string —The issuer's public key (G...)
getType()
Returns the asset type (credit_alphanum4 or credit_alphanum12).
public
getType() : string
Return values
string —Asset type identifier
native()
Creates the native XLM asset
public
static native() : AssetTypeNative
Return values
AssetTypeNative —The native XLM asset
setCode()
Sets the asset code
public
setCode(string $code) : void
Parameters
- $code : string
-
The new asset code
setIssuer()
Sets the issuer account ID
public
setIssuer(string $issuer) : void
Parameters
- $issuer : string
-
The new issuer account ID
toXdr()
Converts the asset to its XDR representation.
public
toXdr() : XdrAsset
Return values
XdrAsset —XDR asset object
toXdrChangeTrustAsset()
Converts this asset to XDR ChangeTrustAsset format
public
toXdrChangeTrustAsset() : XdrChangeTrustAsset
Return values
XdrChangeTrustAsset —XDR format for change trust operations
toXdrTrustlineAsset()
Converts this asset to XDR TrustlineAsset format
public
toXdrTrustlineAsset() : XdrTrustlineAsset
Return values
XdrTrustlineAsset —XDR format for trustline operations