Skip to content

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 name
  • symbol: Short symbol
  • uri: Metadata URI
  • recipient: Address to receive the token
  • ctx: Transaction context

Effects:

  • Creates new RwaToken object
  • Transfers token to recipient
  • Emits Minted event

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
): RwaToken

Returns 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): u64

Events

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 10000000

Minting 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 MintCap can mint tokens
  • Cap should be securely stored
  • Consider using multi-sig for production deployments

Token Properties

  • Token properties are immutable after minting
  • issuer field preserves creator information
  • created_at provides 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

  1. Meaningful Names: Use descriptive names for assets
  2. Metadata URIs: Point to IPFS or other decentralized storage
  3. Issuer Tracking: Use issuer field for provenance
  4. Document Linking: Register documents promptly after minting

Next Steps