75 lines
2.1 KiB
Python
75 lines
2.1 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""
|
||
|
|
Example: Tokenize ISO-20022 message
|
||
|
|
"""
|
||
|
|
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
import json
|
||
|
|
|
||
|
|
# Add parent directory to path
|
||
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
|
||
|
|
|
||
|
|
from parsers.iso20022_parser import ISO20022Parser
|
||
|
|
from financial_tokenization_service import FireflyClient, FinancialTokenizationService
|
||
|
|
|
||
|
|
# Configuration
|
||
|
|
FIREFLY_API_URL = os.getenv('FIREFLY_API_URL', 'http://firefly-api:5000')
|
||
|
|
FIREFLY_API_KEY = os.getenv('FIREFLY_API_KEY', '')
|
||
|
|
|
||
|
|
# Sample ISO-20022 pacs.008 message
|
||
|
|
SAMPLE_PACS008 = """<?xml version="1.0" encoding="UTF-8"?>
|
||
|
|
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pacs.008.001.10">
|
||
|
|
<FIToFICstmrCdtTrf>
|
||
|
|
<GrpHdr>
|
||
|
|
<MsgId>MSG001</MsgId>
|
||
|
|
<CreDtTm>2024-01-01T00:00:00</CreDtTm>
|
||
|
|
<NbOfTxs>1</NbOfTxs>
|
||
|
|
</GrpHdr>
|
||
|
|
<CdtTrfTxInf>
|
||
|
|
<PmtId>
|
||
|
|
<InstrId>INSTR001</InstrId>
|
||
|
|
<EndToEndId>E2E001</EndToEndId>
|
||
|
|
<TxId>TX001</TxId>
|
||
|
|
</PmtId>
|
||
|
|
<Amt>
|
||
|
|
<InstdAmt Ccy="USD">1000.00</InstdAmt>
|
||
|
|
</Amt>
|
||
|
|
<Cdtr>
|
||
|
|
<Nm>Creditor Name</Nm>
|
||
|
|
</Cdtr>
|
||
|
|
<RmtInf>
|
||
|
|
<Ustrd>Payment for services</Ustrd>
|
||
|
|
</RmtInf>
|
||
|
|
</CdtTrfTxInf>
|
||
|
|
</FIToFICstmrCdtTrf>
|
||
|
|
</Document>"""
|
||
|
|
|
||
|
|
def main():
|
||
|
|
"""Main function"""
|
||
|
|
print("Tokenizing ISO-20022 message...")
|
||
|
|
|
||
|
|
# Initialize clients
|
||
|
|
firefly_client = FireflyClient(FIREFLY_API_URL, FIREFLY_API_KEY)
|
||
|
|
tokenization_service = FinancialTokenizationService(firefly_client)
|
||
|
|
|
||
|
|
# Tokenize message
|
||
|
|
try:
|
||
|
|
result = tokenization_service.tokenize_iso20022(
|
||
|
|
SAMPLE_PACS008,
|
||
|
|
"pacs008_001.xml"
|
||
|
|
)
|
||
|
|
|
||
|
|
print(f"✅ Tokenization successful!")
|
||
|
|
print(f"Message ID: {result['messageId']}")
|
||
|
|
print(f"NFT ID: {result['nft']['id']}")
|
||
|
|
print(f"IPFS ID: {result['ipfsId']}")
|
||
|
|
print(f"Parsed data: {json.dumps(result['parsed'], indent=2)}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"❌ Tokenization failed: {e}")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
if __name__ == '__main__':
|
||
|
|
main()
|
||
|
|
|