# Sign and Submit Transaction

And you can integrate more things or your D.app features with [Transactions](/reference/wallet-methods/transactions.md)methods

{% tabs %}
{% tab title="Aptos" %}

### 1.1. Single signer transaction

1. Generate transaction using[Transactions](/reference/wallet-methods/transactions.md#generate-transaction)

```javascript
payload = {
    "type": "entry_function_payload",
    "function": "0x1::coin::transfer",
    "type_arguments": ["0x1::aptos_coin::AptosCoin"],
    "arguments": [
        "0x...", // recipient adddress
        "1000", // amount of APT - decimals = 8
    ]
}

rawTransaction = (await fewcha.aptos.generateTransaction(payload)).data;
```

&#x20; 2\.  Then [Transactions](/reference/wallet-methods/transactions.md#sign-and-submit-transaction)

```javascript
// Simulate transaction before submission (Optional)
simulateRes = (await fewcha.simulateTransaction(rawTransaction)).data;

// Sign then submit
signedTx = (await fewcha.signTransaction(rawTransaction)).data;
txHash = (await fewcha.aptos.submitTransaction(signedTx)).data;

// Or Sign and submit
txHash = (await fewcha.aptos.signAndSubmitTransaction(rawTransaction)).data;
```

### 1.2. Multiple agent transaction

1. Generate transaction using[Transactions](/reference/wallet-methods/transactions.md#generate-transaction)

```javascript
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 = (await 
    fewcha.aptos.generateMultiAgentTransaction(
        payload, 
        secondarySigners, 
        options
    )
).data;
```

&#x20; 2\.  Get signatures

```javascript
primaryPubKey = (await fewcha.account()).data.publicKey;
primarySignedTx = (await 
    fewcha.aptos.signMultiAgentTransaction(
        rawMultiAgentTransaction
    )
).data;

// Change account to the secondary signers specified from the transaction generation step
secondaryPubKey = (await fewcha.account()).data.publicKey;
secondarySignedTx = (await 
    fewcha.aptos.signMultiAgentTransaction(
        rawMultiAgentTransaction
    )
).data;
```

&#x20; 3\.  Submit (or simulate) transaction

```javascript
// Simulate
simulateRes = (await fewcha.aptos.simulateMultiAgentTransaction(
    rawMultiAgentTransaction, // multiAgentTxn
    [options.sender, ...secondarySigners], // addresses
    [primaryPubKey, secondaryPubKey], // pubKeys
)).data;

// Submit
txnHash = (await fewcha.aptos.submitSignedBCSMultiAgentTransaction(
    rawMultiAgentTransaction, // multiAgentTxn
    [options.sender, ...secondarySigners], // addresses
    [primaryPubKey, secondaryPubKey], // pubKeys
    [primarySignedTx, secondarySignedTx] // signatures
)).data;
```

### 1.3. Multiple signature transaction

1. Collection account public keys and generate multi-sign address

```javascript
firstPubKey = (await fewcha.account()).data.publicKey;
secondPubKey = (await fewcha.account()).data.publicKey;
thirdPubKey = (await fewcha.account()).data.publicKey;

const {address, publicKey} = (await fewcha.aptos.getMultiSignAccount(
    [firstPubKey, secondPubKey, thirdPubKey], // list signer publicKeys
    2 // threshold - the number of signature made the transaction valid
)).data;

```

&#x20; 2\.  Generate transaction using[Transactions](/reference/wallet-methods/transactions.md#generate-transaction)

```javascript
payload = {
    "type": "entry_function_payload",
    "function": "0x1::coin::transfer",
    "type_arguments": ["0x1::aptos_coin::AptosCoin"],
    "arguments": [
        "0x...", // recipient adddress
        "1000", // amount of APT - decimals = 8
    ]
}

options = {
    // Multi-sign address
    "sender": "0x..."
    // Other options...
}

rawTransaction = (await 
    fewcha.aptos.generateTransaction(
        payload, 
        options
    )
).data;
```

&#x20; 3\.  Get at least **threshold** signatures from the list signers

```javascript
firstSignature = (await fewcha.aptos.signMultiSignTransaction(rawTransaction)).data;
thirdSignature = (await fewcha.aptos.signMultiSignTransaction(rawTransaction)).data;
```

&#x20; 4\.  Submit (or simulate) transaction

<pre class="language-javascript"><code class="lang-javascript">// Simulate transaction before submission (Optional)
simulateRes = (await fewcha.simulateTransaction(rawTransaction)).data;

<strong>txnHash = (await fewcha.aptos.submitSignedBCSMultiSignTransaction(
</strong><strong>    rawTransaction, // Transaction
</strong><strong>    [0,2], // Bitmap - 0 is index of first signer, 2 is index of third signer
</strong><strong>    publicKey, // multi-sign public key we got from step 1
</strong><strong>    [firstSignature, thirdSignature]
</strong><strong>)).data;
</strong></code></pre>

{% endtab %}

{% tab title="SUI" %}

1. Construct transaction payload

```
payload = {
  suiObjectId: "0x...",
  gasBudget: 1000,
  recipient: "0x...",
  amount: 1000
}
```

&#x20;2\.  Submit the transaction

```
response = (await fewcha.sui.transferSui(payload)).data
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fewcha.app/get-started/sign-and-submit-transaction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
