@@ -291,12 +291,12 @@ export class TokenClient {
291291 * Directly transfer the specified amount of tokens from account to receiver
292292 * using a single multi signature transaction.
293293 *
294- * @param sender AptosAccount where token from which tokens will be transfered
295- * @param receiver Hex-encoded 32 byte Aptos account address to which tokens will be transfered
294+ * @param sender AptosAccount where token from which tokens will be transferred
295+ * @param receiver Hex-encoded 32 byte Aptos account address to which tokens will be transferred
296296 * @param creator Hex-encoded 32 byte Aptos account address to which created tokens
297297 * @param collectionName Name of collection where token is stored
298298 * @param name Token name
299- * @param amount Amount of tokens which will be transfered
299+ * @param amount Amount of tokens which will be transferred
300300 * @param property_version the version of token PropertyMap with a default value 0.
301301 * @returns The hash of the transaction submitted to the API
302302 */
@@ -352,6 +352,85 @@ export class TokenClient {
352352 return transactionRes . hash ;
353353 }
354354
355+ /**
356+ * Directly transfer the specified amount of tokens from account to receiver
357+ * using a single multi signature transaction.
358+ *
359+ * @param sender AptosAccount where token from which tokens will be transferred
360+ * @param receiver Hex-encoded 32 byte Aptos account address to which tokens will be transferred
361+ * @param creator Hex-encoded 32 byte Aptos account address to which created tokens
362+ * @param collectionName Name of collection where token is stored
363+ * @param name Token name
364+ * @param amount Amount of tokens which will be transferred
365+ * @param fee_payer AptosAccount which will pay fee for transaction
366+ * @param property_version the version of token PropertyMap with a default value 0.
367+ * @returns The hash of the transaction submitted to the API
368+ */
369+ async directTransferTokenWithFeePayer (
370+ sender : AptosAccount ,
371+ receiver : AptosAccount ,
372+ creator : MaybeHexString ,
373+ collectionName : string ,
374+ name : string ,
375+ amount : AnyNumber ,
376+ fee_payer : AptosAccount ,
377+ propertyVersion : AnyNumber = 0 ,
378+ extraArgs ?: OptionalTransactionArgs ,
379+ ) : Promise < string > {
380+ const builder = new TransactionBuilderRemoteABI ( this . aptosClient , { sender : sender . address ( ) , ...extraArgs } ) ;
381+ const rawTxn = await builder . build (
382+ "0x3::token::direct_transfer_script" ,
383+ [ ] ,
384+ [ creator , collectionName , name , propertyVersion , amount ] ,
385+ ) ;
386+
387+ const feePayerTxn = new TxnBuilderTypes . FeePayerRawTransaction (
388+ rawTxn ,
389+ [ TxnBuilderTypes . AccountAddress . fromHex ( receiver . address ( ) ) ] ,
390+ TxnBuilderTypes . AccountAddress . fromHex ( fee_payer . address ( ) ) ,
391+ ) ;
392+
393+ const senderSignature = new TxnBuilderTypes . Ed25519Signature (
394+ sender . signBuffer ( TransactionBuilder . getSigningMessage ( feePayerTxn ) ) . toUint8Array ( ) ,
395+ ) ;
396+
397+ const senderAuthenticator = new TxnBuilderTypes . AccountAuthenticatorEd25519 (
398+ new TxnBuilderTypes . Ed25519PublicKey ( sender . signingKey . publicKey ) ,
399+ senderSignature ,
400+ ) ;
401+
402+ const receiverSignature = new TxnBuilderTypes . Ed25519Signature (
403+ receiver . signBuffer ( TransactionBuilder . getSigningMessage ( feePayerTxn ) ) . toUint8Array ( ) ,
404+ ) ;
405+
406+ const receiverAuthenticator = new TxnBuilderTypes . AccountAuthenticatorEd25519 (
407+ new TxnBuilderTypes . Ed25519PublicKey ( receiver . signingKey . publicKey ) ,
408+ receiverSignature ,
409+ ) ;
410+
411+ const feePayerSignature = new TxnBuilderTypes . Ed25519Signature (
412+ fee_payer . signBuffer ( TransactionBuilder . getSigningMessage ( feePayerTxn ) ) . toUint8Array ( ) ,
413+ ) ;
414+
415+ const feePayerAuthenticator = new TxnBuilderTypes . AccountAuthenticatorEd25519 (
416+ new TxnBuilderTypes . Ed25519PublicKey ( fee_payer . signingKey . publicKey ) ,
417+ feePayerSignature ,
418+ ) ;
419+
420+ const txAuthenticatorFeePayer = new TxnBuilderTypes . TransactionAuthenticatorFeePayer (
421+ senderAuthenticator ,
422+ [ TxnBuilderTypes . AccountAddress . fromHex ( receiver . address ( ) ) ] ,
423+ [ receiverAuthenticator ] ,
424+ { address : TxnBuilderTypes . AccountAddress . fromHex ( fee_payer . address ( ) ) , authenticator : feePayerAuthenticator } ,
425+ ) ;
426+
427+ const bcsTxn = bcsToBytes ( new TxnBuilderTypes . SignedTransaction ( rawTxn , txAuthenticatorFeePayer ) ) ;
428+
429+ const transactionRes = await this . aptosClient . submitSignedBCSTransaction ( bcsTxn ) ;
430+
431+ return transactionRes . hash ;
432+ }
433+
355434 /**
356435 * User opt-in or out direct transfer through a boolean flag
357436 *
0 commit comments