# Signing Transactions

Transactions are a formal action on a blockchain. They can contain a simple sending of Lumen (Payment Operation) or sending tokens creating data on the blockchain network and so on.

In Rabet, use the `rabet.sign` method to send a transaction.

This function accepts a transaction envelope XDR and network type(mainnet or testnet), When you put an XDR string and network type inside this method and call it, Rabet decodes it and shows its details to the user, if the user confirms and signs it, you receive the signed XDR.

{% hint style="info" %}
You should only call the `sign` function after calling the `connect` function. Otherwise, it would return the *not-connected* error.
{% endhint %}

```javascript
// Connect before signing
const xdr = 'AAAAAL...'; // Only string
const network = 'mainnet'; // mainnet / testnet

rabet.sign(xdr, network)
    .then(result => console.log(`Signed xdr: ${result.xdr}`))
    .catch(error => console.error(`Error: ${error.message}`));
```

{% hint style="info" %}
You can also use

`StellarSdk.Networks.PUBLIC`

or `StellarSdk.Networks.`TESTNET

`for the netowrk parameter.`
{% endhint %}

Example of the message that the user will receive when calling the `sign` function:

![](/files/-MTjGehrONu95eNFKynF)

You can use StellarSdk to submit the transaction to the network. Like so:

```javascript
var StellarSdk = require('stellar-sdk');
var server = new StellarSdk.Server('https://horizon-testnet.stellar.org');

const xdr = 'AAAA...';
const envelope = StellarSdk.xdr.TransactionEnvelope.fromXDR(xdr, 'base64');
var transaction = new StellarSdk.Transaction(envelope, StellarSdk.Networks.TESTNET);

server
  .submitTransaction(transaction)
  .then((result) => {
    console.log(result);
  })
  .catch((e) => {
    console.log(e.response.data);
  });
```

You can learn more about Stellar SDKs [here](https://developers.stellar.org/docs/software-and-sdks/).


---

# 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.rabet.io/signing-transactions.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.
