defbuild_prefunded_message_transaction(recipient_address,message):# Build the embedded message transactionmessage_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account sending the message'signer_public_key':user_key_pair.public_key,'recipient_address':recipient_address,'message':message})# Build the embedded prefund transactionprefund_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account funding the transaction fee'signer_public_key':app_key_pair.public_key,# Account receiving the funds'recipient_address':facade.network.public_key_to_address(user_key_pair.public_key),'mosaics':[{'mosaic_id':generate_mosaic_alias_id('symbol.xym'),'amount':0# To be filled once value is known}]})# Build the wrapper complete aggregate transactiontransaction=facade.transaction_factory.create({'type':'aggregate_complete_transaction_v3',# This is the account that will pay for the transaction'signer_public_key':user_key_pair.public_key,'deadline':timestamp.add_hours(2).timestamp,'transactions':[message_transaction,prefund_transaction]})# Calculate total fee, reserving space for a cosignaturetransaction.fee=sc.Amount(fee_mult*(transaction.size+104))# Update the prefund amount to match the total feeprefund_transaction.mosaics[0].amount=transaction.fee# Update the embedded transaction hashestransaction.transactions_hash=sc.Hash256(facade.hash_embedded_transactions([message_transaction,prefund_transaction]).bytes)# Sign the aggregate transaction using the user's signaturefacade.transaction_factory.attach_signature(transaction,facade.sign_transaction(user_key_pair,transaction))# Attach the app's cosignaturetransaction.cosignatures.append(facade.cosign_transaction(app_key_pair,transaction))# Obtain the payloadjson_payload=facade.transaction_factory.attach_signature(transaction,facade.sign_transaction(user_key_pair,transaction))return(transaction,json_payload)
functionbuildPrefundedMessageTransaction(recipientAddress,message){// Build the embedded message transactionconstmessageTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account sending the messagesignerPublicKey:userKeyPair.publicKey,recipientAddress,message});// Build the embedded prefund transactionconstprefundTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account funding the transaction feesignerPublicKey:appKeyPair.publicKey,// Account receiving the fundsrecipientAddress:facade.network.publicKeyToAddress(userKeyPair.publicKey),mosaics:[{mosaicId:generateMosaicAliasId('symbol.xym'),amount:0// To be filled once value is known}]});// Build the wrapper complete aggregate transactionconsttransaction=facade.transactionFactory.create({type:'aggregate_complete_transaction_v3',// This is the account that will pay for the transactionsignerPublicKey:userKeyPair.publicKey,deadline:timestamp.addHours(2).timestamp,transactions:[messageTransaction,prefundTransaction]});// Calculate total fee, reserving space for a cosignaturetransaction.fee=newmodels.Amount(feeMult*(transaction.size+104));// Update the prefund amount to match the total feeprefundTransaction.mosaics[0].amount=transaction.fee;// Update the embedded transaction hashestransaction.transactionsHash=newmodels.Hash256(facade.static.hashEmbeddedTransactions([messageTransaction,prefundTransaction]).bytes);// Sign the aggregate transaction using the user's signaturefacade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(userKeyPair,transaction));// Attach the app's cosignaturetransaction.cosignatures.push(facade.cosignTransaction(appKeyPair,transaction));// Obtain the payloadconstjsonPayload=facade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(userKeyPair,transaction));return{transaction,jsonPayload};}
# Build the embedded message transactionmessage_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account sending the message'signer_public_key':user_key_pair.public_key,'recipient_address':recipient_address,'message':message})
// Build the embedded message transactionconstmessageTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account sending the messagesignerPublicKey:userKeyPair.publicKey,recipientAddress,message});
# Build the embedded prefund transactionprefund_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account funding the transaction fee'signer_public_key':app_key_pair.public_key,# Account receiving the funds'recipient_address':facade.network.public_key_to_address(user_key_pair.public_key),'mosaics':[{'mosaic_id':generate_mosaic_alias_id('symbol.xym'),'amount':0# To be filled once value is known}]})
// Build the embedded prefund transactionconstprefundTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account funding the transaction feesignerPublicKey:appKeyPair.publicKey,// Account receiving the fundsrecipientAddress:facade.network.publicKeyToAddress(userKeyPair.publicKey),mosaics:[{mosaicId:generateMosaicAliasId('symbol.xym'),amount:0// To be filled once value is known}]});
# Build the wrapper complete aggregate transactiontransaction=facade.transaction_factory.create({'type':'aggregate_complete_transaction_v3',# This is the account that will pay for the transaction'signer_public_key':user_key_pair.public_key,'deadline':timestamp.add_hours(2).timestamp,'transactions':[message_transaction,prefund_transaction]})# Calculate total fee, reserving space for a cosignaturetransaction.fee=sc.Amount(fee_mult*(transaction.size+104))# Update the prefund amount to match the total feeprefund_transaction.mosaics[0].amount=transaction.fee# Update the embedded transaction hashestransaction.transactions_hash=sc.Hash256(facade.hash_embedded_transactions([message_transaction,prefund_transaction]).bytes)
// Build the wrapper complete aggregate transactionconsttransaction=facade.transactionFactory.create({type:'aggregate_complete_transaction_v3',// This is the account that will pay for the transactionsignerPublicKey:userKeyPair.publicKey,deadline:timestamp.addHours(2).timestamp,transactions:[messageTransaction,prefundTransaction]});// Calculate total fee, reserving space for a cosignaturetransaction.fee=newmodels.Amount(feeMult*(transaction.size+104));// Update the prefund amount to match the total feeprefundTransaction.mosaics[0].amount=transaction.fee;// Update the embedded transaction hashestransaction.transactionsHash=newmodels.Hash256(facade.static.hashEmbeddedTransactions([messageTransaction,prefundTransaction]).bytes);
# Sign the aggregate transaction using the user's signaturefacade.transaction_factory.attach_signature(transaction,facade.sign_transaction(user_key_pair,transaction))# Attach the app's cosignaturetransaction.cosignatures.append(facade.cosign_transaction(app_key_pair,transaction))# Obtain the payloadjson_payload=facade.transaction_factory.attach_signature(transaction,facade.sign_transaction(user_key_pair,transaction))
// Sign the aggregate transaction using the user's signaturefacade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(userKeyPair,transaction));// Attach the app's cosignaturetransaction.cosignatures.push(facade.cosignTransaction(appKeyPair,transaction));// Obtain the payloadconstjsonPayload=facade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(userKeyPair,transaction));
defbuild_sponsored_message_transaction(recipient_address,message):# Build the embedded message transactionmessage_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account sending the message'signer_public_key':user_key_pair.public_key,'recipient_address':recipient_address,'message':message})# Build the embedded filler transactionfiller_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# The application account is both the sender and the recipient# and there is no `mosaics` field'signer_public_key':app_key_pair.public_key,'recipient_address':facade.network.public_key_to_address(app_key_pair.public_key)})# Build the wrapper complete aggregate transactiontransaction=facade.transaction_factory.create({'type':'aggregate_complete_transaction_v3',# This is the account that will pay for the transaction'signer_public_key':app_key_pair.public_key,'deadline':timestamp.add_hours(2).timestamp,'transactions_hash':facade.hash_embedded_transactions([message_transaction,filler_transaction]),'transactions':[message_transaction,filler_transaction]})# Calculate total fee, reserving space for a cosignaturetransaction.fee=sc.Amount(fee_mult*(transaction.size+104))# Sign the aggregate transaction using the app's signaturefacade.transaction_factory.attach_signature(transaction,facade.sign_transaction(app_key_pair,transaction))# Attach the users's cosignaturetransaction.cosignatures.append(facade.cosign_transaction(user_key_pair,transaction))# Obtain the payloadjson_payload=facade.transaction_factory.attach_signature(transaction,facade.sign_transaction(app_key_pair,transaction))return(transaction,json_payload)
functionbuildSponsoredMessageTransaction(recipientAddress,message){// Build the embedded message transactionconstmessageTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account sending the messagesignerPublicKey:userKeyPair.publicKey,recipientAddress,message});// Build the embedded filler transactionconstfillerTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// The application account is both the sender and the recipient// and there is no `mosaics` fieldsignerPublicKey:appKeyPair.publicKey,recipientAddress:facade.network.publicKeyToAddress(appKeyPair.publicKey)});// Build the wrapper complete aggregate transactionconsttransaction=facade.transactionFactory.create({type:'aggregate_complete_transaction_v3',// This is the account that will pay for the transactionsignerPublicKey:appKeyPair.publicKey,deadline:timestamp.addHours(2).timestamp,transactionsHash:facade.static.hashEmbeddedTransactions([messageTransaction,fillerTransaction]),transactions:[messageTransaction,fillerTransaction]});// Calculate total fee, reserving space for a cosignaturetransaction.fee=newmodels.Amount(feeMult*(transaction.size+104));// Sign the aggregate transaction using the app's signaturefacade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(appKeyPair,transaction));// Attach the user's cosignaturetransaction.cosignatures.push(facade.cosignTransaction(userKeyPair,transaction));// Obtain the payloadconstjsonPayload=facade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(appKeyPair,transaction));return{transaction,jsonPayload};}
# Build the embedded message transactionmessage_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# Account sending the message'signer_public_key':user_key_pair.public_key,'recipient_address':recipient_address,'message':message})
// Build the embedded message transactionconstmessageTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// Account sending the messagesignerPublicKey:userKeyPair.publicKey,recipientAddress,message});
# Build the embedded filler transactionfiller_transaction=facade.transaction_factory.create_embedded({'type':'transfer_transaction_v1',# The application account is both the sender and the recipient# and there is no `mosaics` field'signer_public_key':app_key_pair.public_key,'recipient_address':facade.network.public_key_to_address(app_key_pair.public_key)})
// Build the embedded filler transactionconstfillerTransaction=facade.transactionFactory.createEmbedded({type:'transfer_transaction_v1',// The application account is both the sender and the recipient// and there is no `mosaics` fieldsignerPublicKey:appKeyPair.publicKey,recipientAddress:facade.network.publicKeyToAddress(appKeyPair.publicKey)});
# Build the wrapper complete aggregate transactiontransaction=facade.transaction_factory.create({'type':'aggregate_complete_transaction_v3',# This is the account that will pay for the transaction'signer_public_key':app_key_pair.public_key,'deadline':timestamp.add_hours(2).timestamp,'transactions_hash':facade.hash_embedded_transactions([message_transaction,filler_transaction]),'transactions':[message_transaction,filler_transaction]})# Calculate total fee, reserving space for a cosignaturetransaction.fee=sc.Amount(fee_mult*(transaction.size+104))
// Build the wrapper complete aggregate transactionconsttransaction=facade.transactionFactory.create({type:'aggregate_complete_transaction_v3',// This is the account that will pay for the transactionsignerPublicKey:appKeyPair.publicKey,deadline:timestamp.addHours(2).timestamp,transactionsHash:facade.static.hashEmbeddedTransactions([messageTransaction,fillerTransaction]),transactions:[messageTransaction,fillerTransaction]});// Calculate total fee, reserving space for a cosignaturetransaction.fee=newmodels.Amount(feeMult*(transaction.size+104));
# Sign the aggregate transaction using the app's signaturefacade.transaction_factory.attach_signature(transaction,facade.sign_transaction(app_key_pair,transaction))# Attach the users's cosignaturetransaction.cosignatures.append(facade.cosign_transaction(user_key_pair,transaction))# Obtain the payloadjson_payload=facade.transaction_factory.attach_signature(transaction,facade.sign_transaction(app_key_pair,transaction))
// Sign the aggregate transaction using the app's signaturefacade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(appKeyPair,transaction));// Attach the user's cosignaturetransaction.cosignatures.push(facade.cosignTransaction(userKeyPair,transaction));// Obtain the payloadconstjsonPayload=facade.transactionFactory.static.attachSignature(transaction,facade.signTransaction(appKeyPair,transaction));