RWA Token Module
The rwa_token module provides non-fungible tokens representing unique real-world assets. Each token is an owned object that can be transferred and traded on the marketplace.
Overview
RWA tokens are NFT-like objects that represent ownership of real-world assets. They serve as the foundation for the entire Iyup ecosystem, linking assets to documents, enabling marketplace trading, and controlling access to encrypted documents.
Key Structures
RwaToken
The main token structure representing an RWA:
public struct RwaToken has key, store {
id: UID,
name: String, // Human-readable name (e.g., "Property #123")
symbol: String, // Short symbol (e.g., "PROP")
uri: String, // Metadata URI (off-chain pointer)
issuer: address, // Original issuer/creator
created_at: u64, // Creation timestamp (ms)
}MintCap
Minting authority held by the deployer:
public struct MintCap has key, store {
id: UID,
issuer: address,
}Main Functions
mint()
Mint a new RWA token and transfer to recipient:
public entry fun mint(
_cap: &MintCap,
name: String,
symbol: String,
uri: String,
recipient: address,
ctx: &mut TxContext
)Parameters:
_cap: Reference to MintCap (authorization)name: Human-readable namesymbol: Short symboluri: Metadata URIrecipient: Address to receive the tokenctx: Transaction context
Effects:
- Creates new
RwaTokenobject - Transfers token to recipient
- Emits
Mintedevent
mint_to_tx()
Mint token for use in programmable transactions:
public fun mint_to_tx(
_cap: &MintCap,
name: String,
symbol: String,
uri: String,
recipient: address,
ctx: &mut TxContext
): RwaTokenReturns the token object instead of transferring it directly.
Getters
View functions to read token properties:
public fun name(token: &RwaToken): String
public fun symbol(token: &RwaToken): String
public fun uri(token: &RwaToken): String
public fun issuer(token: &RwaToken): address
public fun created_at(token: &RwaToken): u64Events
Minted
Emitted when a new token is minted:
public struct Minted has copy, drop {
recipient: address,
issuer: address,
timestamp: u64,
}Usage Examples
Minting via CLI
sui client call \
--package <PACKAGE_ID> \
--module rwa_token \
--function mint \
--args <MINT_CAP_ID> "Property #123" "PROP" "https://metadata.example.com" <RECIPIENT_ADDRESS> \
--gas-budget 10000000Minting via TypeScript
const tx = new TransactionBlock();
tx.moveCall({
target: `${PACKAGE_ID}::rwa_token::mint`,
arguments: [
tx.object(MINT_CAP_ID),
tx.pure.string("Property #123"),
tx.pure.string("PROP"),
tx.pure.string("https://metadata.example.com"),
tx.pure.address(recipientAddress),
],
});
await suiClient.signAndExecuteTransactionBlock({
signer: keypair,
transactionBlock: tx,
});Integration Points
Marketplace
Tokens can be listed for sale on the marketplace. The marketplace escrow system handles token transfers during trading.
Document Vault
Tokens are linked to documents in the vault. The token address serves as the key for document lookups.
Access Control
Token ownership determines access to encrypted documents. Only token owners can retrieve access keys.
Security Considerations
Minting Authority
- Only holders of
MintCapcan mint tokens - Cap should be securely stored
- Consider using multi-sig for production deployments
Token Properties
- Token properties are immutable after minting
issuerfield preserves creator informationcreated_atprovides audit trail
Transfer Safety
- Tokens use standard Sui transfer mechanisms
- Ownership changes are recorded on-chain
- Transfer events can be indexed off-chain
Best Practices
- Meaningful Names: Use descriptive names for assets
- Metadata URIs: Point to IPFS or other decentralized storage
- Issuer Tracking: Use issuer field for provenance
- Document Linking: Register documents promptly after minting
Next Steps
- Learn about Marketplace trading
- Understand Document Vault integration
- Review Access Control mechanisms