> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# sendTransaction

> Send a transaction with full parameter control.

## Function Signature

```dart theme={null}
Future<String> sendTransaction({
  required String chainId,
  required String to,
  String? from,
  String? value,
  String? data,
  String? gas,
  String? gasPrice,
  String? maxFeePerGas,
  String? maxPriorityFeePerGas,
  String? nonce,
})
```

## Description

Signs and broadcasts a transaction to the network with full control over all transaction parameters.

## Parameters

| Parameter              | Type     | Required | Description                                 |
| ---------------------- | -------- | -------- | ------------------------------------------- |
| `chainId`              | `String` | Yes      | The chain ID in CAIP-2 format               |
| `to`                   | `String` | Yes      | The recipient/contract address              |
| `from`                 | `String` | No       | Sender address (defaults to wallet address) |
| `value`                | `String` | No       | Value in wei (hex string)                   |
| `data`                 | `String` | No       | Transaction data (hex string)               |
| `gas`                  | `String` | No       | Gas limit (hex string)                      |
| `gasPrice`             | `String` | No       | Gas price for legacy transactions (hex)     |
| `maxFeePerGas`         | `String` | No       | Max fee per gas for EIP-1559 (hex)          |
| `maxPriorityFeePerGas` | `String` | No       | Max priority fee for EIP-1559 (hex)         |
| `nonce`                | `String` | No       | Transaction nonce (hex string)              |

## Returns

**`String`** - The transaction hash.

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

// Simple ETH transfer
final txHash = await portal.sendTransaction(
  chainId: 'eip155:1',
  to: '0xRecipientAddress',
  value: '0xDE0B6B3A7640000', // 1 ETH in wei (hex)
);

print('Transaction hash: $txHash');
```

### EIP-1559 Transaction

```dart theme={null}
final txHash = await portal.sendTransaction(
  chainId: 'eip155:1',
  to: '0xRecipientAddress',
  value: '0x10',
  maxFeePerGas: '0x3B9ACA00',
  maxPriorityFeePerGas: '0x3B9ACA00',
);
```

### Contract Interaction

```dart theme={null}
final txHash = await portal.sendTransaction(
  chainId: 'eip155:1',
  to: '0xContractAddress',
  data: '0xa9059cbb...', // Encoded function call
  gas: '0x5208',
);
```

## Errors

| Code                 | Description                       |
| -------------------- | --------------------------------- |
| `NOT_INITIALIZED`    | Portal was not initialized        |
| `TRANSACTION_FAILED` | The transaction failed            |
| `INSUFFICIENT_FUNDS` | Not enough funds for gas or value |

## Related

* [Sign a transaction guide](../guide/sign-a-transaction)
* [sendAsset](./sendasset)
* [request](./request)
