# Submitting a contract transaction request

Before requesting a transaction, ensure that you encode the value in hexadecimal format.

```javascript
const value = "0x0"
```

You also need to add the necessary parameters before requesting a transaction.

```javascript
const from = userAddress //the address you're sending from (connected users address)
const to = "0x0000000000000000000000000000000000000000" // the address you're sending the transaction to 
```

Now we need to get the data to send to represent the contract data. In this example we are approving 0.1 BUSD

```javascript
// create the tx object
// BUSD contract address: 0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7
const contractAddress = "0x78867BbEeF44f2326bF8DDd1941a4439382EF2A7";
// Approve function ABI
const abi = [
  {
    inputs: [
      { internalType: "address", name: "spender", type: "address" },
      { internalType: "uint256", name: "amount", type: "uint256" },
    ],
    name: "approve",
    outputs: [{ internalType: "bool", name: "", type: "bool" }],
    stateMutability: "nonpayable",
    type: "function",
  },
];
const contract = new ethers.Contract(contractAddress, abi);

// Set the parameters for the transaction
const spender = userAddress; // the address of the spender (user connected)
const amount = ethers.parseEther("0.1"); // the amount to approve
const data = contract.interface.encodeFunctionData("approve", [
     spender,
     amount,
]);
```

Next, create the transaction object

```javascript
const tx = {
  from,
  to,
  data,
  value,
},
```

Finally, obtain the chain ID, which can be found at the following URL: (<https://chainlist.org>)

```javascript
const chainId = 1; // ETH chain id
```

<mark style="color:green;">`POST`</mark> `https://api.alturanft.com/api/alturaguard/request`

#### Request Body

| Name                                            | Type   | Description                             |
| ----------------------------------------------- | ------ | --------------------------------------- |
| token<mark style="color:red;">\*</mark>         | String | User token recieved when authenticating |
| reqParameters<mark style="color:red;">\*</mark> | array  | `["transaction", tx, chainId]`          |

{% tabs %}
{% tab title="200: OK requestId" %}

```javascript
requestId
```

{% endtab %}

{% tab title="400: Bad Request Invalid reqParameters" %}

{% endtab %}

{% tab title="401: Unauthorized Invalid token" %}

{% 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.altura.com/altura-documentation/api-reference/altura-guard-ii/transaction-requests/submitting-a-contract-transaction-request.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.
