// Simulate transaction before submission (Optional)simulateRes = (awaitfewcha.simulateTransaction(rawTransaction)).data;// Sign then submitsignedTx = (awaitfewcha.signTransaction(rawTransaction)).data;txHash = (awaitfewcha.aptos.submitTransaction(signedTx)).data;// Or Sign and submittxHash = (awaitfewcha.aptos.signAndSubmitTransaction(rawTransaction)).data;
1.2. Multiple agent transaction
payload = {"type":"entry_function_payload","function":"0x3::token::direct_transfer_script","type_arguments": [],"arguments": ["0x...",// creator address"Fewcha Membership",// token collection"Member Level 1",// token name"0",// property_version"1",// amount of token ]}// List of secondary addresses// direct_transfer_script// 2 signers is required (primary and 1 secondary signer)secondarySigners = ["0x...",]options = {// Primary signer// If not specified, the current connected account will be selected"sender":"0x..."// Other options...}rawMultiAgentTransaction = (awaitfewcha.aptos.generateMultiAgentTransaction( payload, secondarySigners, options )).data;
2. Get signatures
primaryPubKey = (awaitfewcha.account()).data.publicKey;primarySignedTx = (awaitfewcha.aptos.signMultiAgentTransaction( rawMultiAgentTransaction )).data;// Change account to the secondary signers specified from the transaction generation stepsecondaryPubKey = (awaitfewcha.account()).data.publicKey;secondarySignedTx = (awaitfewcha.aptos.signMultiAgentTransaction( rawMultiAgentTransaction )).data;
Collection account public keys and generate multi-sign address
firstPubKey = (awaitfewcha.account()).data.publicKey;secondPubKey = (awaitfewcha.account()).data.publicKey;thirdPubKey = (awaitfewcha.account()).data.publicKey;const {address,publicKey} = (awaitfewcha.aptos.getMultiSignAccount( [firstPubKey, secondPubKey, thirdPubKey],// list signer publicKeys2// threshold - the number of signature made the transaction valid)).data;
// Simulate transaction before submission (Optional)simulateRes = (awaitfewcha.simulateTransaction(rawTransaction)).data;txnHash = (awaitfewcha.aptos.submitSignedBCSMultiSignTransaction( rawTransaction,// Transaction [0,2],// Bitmap - 0 is index of first signer, 2 is index of third signer publicKey,// multi-sign public key we got from step 1 [firstSignature, thirdSignature])).data;