# Transaction Builder

## TS SDK Transaction Builder <a href="#ts-sdk-transaction-builder" id="ts-sdk-transaction-builder"></a>

The SDK provides a simplified and meaningful transaction builder flow to handles the transaction creation lifecycle.

The transaction builder is separated to different namespaces for each transaction step in the transaction submission flow. Each namespace/step can be accessed by initiating the Endless class

* **build** - Build a raw transaction that can be signed and then submitted to chain
* **simulate** - Simulate a transaction before signing and submitting to chain
* **sign** - Sign a raw transaction to later submit to chain
* **submit** - Submit a transaction to chain

### Submit transaction <a href="#submit-transaction" id="submit-transaction"></a>

**Simple transaction**

```js
// build a transaction
const transaction = await endless.transaction.build.simple({
  sender: alice.accountAddress,
  data: {
    function: "0x1::endless_coin::transfer",
    typeArguments: [],
    functionArguments: [bob.accountAddress, 100],
  },
});

// using sign and submit separately
const senderAuthenticator = endless.transaction.sign({
  signer: alice,
  transaction,
});
const committedTransaction = await endless.transaction.submit.simple({
  transaction,
  senderAuthenticator,
});

// or using signAndSubmit combined
const committedTransaction = await endless.signAndSubmitTransaction({
  signer: alice,
  transaction,
});
```

### Simulate transaction <a href="#simulate-transaction" id="simulate-transaction"></a>

**Simple transaction**

```js
const transaction = await endless.transaction.build.simple({
  sender: alice.accountAddress,
  data: {
    function: "0x1::endless_coin::transfer",
    functionArguments: [bob.accountAddress, 100],
  },
});
const [userTransactionResponse] = await endless.transaction.simulate.simple({
  signerPublicKey: alice.publicKey,
  transaction,
});
```


---

# 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.endless.link/endless/devbuild/build/endless-sdks/typescript-sdk/transaction-builder.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.
