@@ -168,46 +168,55 @@ Transaction<TransactionData> transferTransaction =
168168The SDK supports offline token transfers, where the transaction is prepared by the sender and can be transferred offline (e.g., via NFC, QR code, or file) to the recipient.
169169
170170``` java
171- import com.unicity.sdk.OfflineStateTransitionClient ;
172- import com.unicity.sdk.transaction.* ;
173-
174- // Step 1: Sender creates offline transaction
175- OfflineStateTransitionClient offlineClient = new OfflineStateTransitionClient (aggregatorClient);
176-
177- // Create transaction data
171+ // Step 1: Sender creates offline commitment
178172TransactionData transactionData = TransactionData . create(
179173 token. getState(),
180174 recipientAddress. toString(),
181- randomBytes(32 ),
182- dataHash,
183- messageBytes
175+ randomBytes(32 ), // salt
176+ dataHash, // optional data hash
177+ messageBytes // optional message
184178). get();
185179
186- // Create offline commitment (signed by sender)
187- OfflineCommitment offlineCommitment = offlineClient. createOfflineCommitment(
188- transactionData,
189- senderSigningService
180+ // Create authenticator (signed by sender)
181+ Authenticator authenticator = Authenticator . create(
182+ senderSigningService,
183+ transactionData. getHash(),
184+ transactionData. getSourceState(). getHash()
190185). get();
191186
192- // Create offline transaction package
193- OfflineTransaction offlineTransaction = new OfflineTransaction (offlineCommitment, token);
187+ // Create request ID
188+ RequestId requestId = RequestId . create(
189+ senderSigningService. getPublicKey(),
190+ transactionData. getSourceState(). getHash()
191+ ). get();
194192
195- // Serialize to JSON for offline transfer
196- String offlineTransactionJson = offlineTransaction. toJSONString();
193+ // Create commitment
194+ Commitment<TransactionData > commitment = new Commitment<> (
195+ requestId,
196+ transactionData,
197+ authenticator
198+ );
197199
198- // Step 2: Transfer JSON to recipient offline (NFC, QR code, file, etc.)
200+ // Step 2: Transfer commitment data offline (NFC, QR code, file, etc.)
201+ // In a real scenario, serialize commitment and token data for transfer
199202
200- // Step 3: Recipient processes the offline transaction
201- OfflineTransaction receivedTransaction = OfflineTransaction . fromJSON(offlineTransactionJson ). get();
203+ // Step 3: Recipient submits the commitment online
204+ SubmitCommitmentResponse response = client . submitCommitment(commitment ). get();
202205
203- // Submit to aggregator
204- Transaction<?> confirmedTransaction = offlineClient. submitOfflineTransaction(
205- receivedTransaction. getCommitment()
206+ // Wait for inclusion proof
207+ InclusionProof inclusionProof = InclusionProofUtils . waitInclusionProof(
208+ client,
209+ commitment
206210). get();
207211
212+ // Create transaction with proof
213+ Transaction<TransactionData > confirmedTransaction =
214+ client. createTransaction(commitment, inclusionProof). get();
215+
208216// Finish transaction with recipient's state
209- Token<Transaction<MintTransactionData<?> > > updatedToken = client. finishTransaction(
210- receivedTransaction. getToken(),
217+ TokenState recipientTokenState = TokenState . create(recipientPredicate, recipientData);
218+ Token<?> updatedToken = client. finishTransaction(
219+ token,
211220 recipientTokenState,
212221 confirmedTransaction
213222). get();
@@ -262,10 +271,19 @@ The standard JVM version uses:
262271The SDK follows a modular architecture:
263272
264273- ** ` api ` ** : Core API interfaces and aggregator client
265- - ** ` token ` ** : Token-related classes (TokenId, TokenType, TokenState)
266- - ** ` transaction ` ** : Transaction types (Mint, Transfer, Swap)
267- - ** ` predicate ` ** : Ownership predicates and authorization
268- - ** ` shared ` ** : Common utilities (CBOR, hashing, signing)
274+ - ** ` api ` ** : Core API interfaces and aggregator client
275+ - ** ` address ` ** : Address schemes and implementations
276+ - ** ` predicate ` ** : Ownership predicates (Masked, Unmasked, Burn) and authorization
277+ - ** ` serializer ` ** : CBOR and JSON serializers for tokens and transactions
278+ - ** ` token ` ** : Token-related classes (TokenId, TokenType, TokenState) and fungible token support
279+ - ** ` transaction ` ** : Transaction types (Mint, Transfer, Commitment) and builders
280+ - ** ` shared ` ** : Common utilities
281+ - ` cbor ` : CBOR encoding/decoding
282+ - ` hash ` : Cryptographic hashing (SHA256, SHA224, SHA384, SHA512, RIPEMD160)
283+ - ` jsonrpc ` : JSON-RPC transport layer
284+ - ` signing ` : Digital signature support (ECDSA secp256k1)
285+ - ` smt ` /` smst ` : Sparse Merkle Tree implementations
286+ - ` util ` : BitString and other utilities
269287- ** ` utils ` ** : Helper utilities
270288
271289## Error Handling
0 commit comments