> ## 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.

# approveAndSubmit

> Approves a token delegation and signs and broadcasts the resulting transaction(s) in one call, returning the submitted transaction hashes.

**Function Signature**

```swift theme={null}
public func approveAndSubmit(
    request: ApproveDelegationRequest,
    options: DelegationSubmitOptions
) async throws -> DelegationSubmitResult

// Convenience overload, using the signer Portal already installed for you
public func approveAndSubmit(
    request: ApproveDelegationRequest
) async throws -> DelegationSubmitResult
```

**Description**

Builds the approval transaction(s) for a token delegation, then signs and broadcasts each one sequentially and returns the resulting transaction hashes. This replaces calling `approve` and signing the returned transactions yourself.

<Warning>
  `approveAndSubmit` broadcasts each transaction and returns as soon as it is accepted by the network. It **does not wait for on-chain confirmation**. A hash in `DelegationSubmitResult.hashes` means the transaction was submitted, not that it succeeded — the approval can still revert. If your flow depends on the delegation being active, wait for the receipt yourself, or poll `getStatus` before proceeding.
</Warning>

**Parameters**

| Parameter | Type                       | Required | Description                                                                                                 |
| --------- | -------------------------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| `request` | `ApproveDelegationRequest` | Yes      | The approval to build and submit.                                                                           |
| `options` | `DelegationSubmitOptions`  | No       | Per-call signer override and progress callback. Omit the argument entirely to use the convenience overload. |

`ApproveDelegationRequest`:

| Parameter         | Type     | Required | Description                                                                                  |
| ----------------- | -------- | -------- | -------------------------------------------------------------------------------------------- |
| `chain`           | `String` | Yes      | CAIP-2 chain ID, for example `eip155:11155111` or `solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1`. |
| `token`           | `String` | Yes      | Token symbol or contract address, for example `USDC`.                                        |
| `delegateAddress` | `String` | Yes      | The address being granted permission to spend the tokens.                                    |
| `amount`          | `String` | Yes      | The amount to delegate, for example `0.01`.                                                  |

`DelegationSubmitOptions`:

| Parameter                | Type                                    | Required | Description                                                                                                                                               |
| ------------------------ | --------------------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `signAndSendTransaction` | `DelegationSignAndSend?`                | No       | Per-call signer override. Takes priority over the instance signer set with `setSignAndSendTransaction(_:)`.                                               |
| `onProgress`             | `((DelegationSubmitProgress) -> Void)?` | No       | Called as each transaction is signed and submitted. `progress.step` is `.signing` or `.submitted`, and `progress.hash` is populated only on `.submitted`. |

**Returns**

A `DelegationSubmitResult` containing:

| Field    | Type       | Description                                                                        |
| -------- | ---------- | ---------------------------------------------------------------------------------- |
| `hashes` | `[String]` | One hash per broadcast transaction, in submission order. Submitted, not confirmed. |

**Throws**

| Error                                                     | When                                                                                                                                                |
| --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DelegationsError.noSignerConfigured`                     | No signer was available. This cannot happen on `portal.delegations`, which `Portal` wires for you — only when you construct `Delegations` yourself. |
| `DelegationsError.noTransactions`                         | The approval response contained no transactions to submit.                                                                                          |
| `DelegationsError.invalidTransactionHash(index:chainId:)` | The signer returned a value that is not a usable hash for that chain. `index` identifies which transaction in the sequence it was.                  |
| `URLError` and decoding errors                            | The request to build the approval failed.                                                                                                           |

**Example Usage**

```swift theme={null}
import PortalSwift

Task {
    do {
        let request = ApproveDelegationRequest(
            chain: "eip155:11155111",
            token: "USDC",
            delegateAddress: "0xa944e86eb36f039becd1843132347eb5b8501562",
            amount: "0.01"
        )

        let result = try await portal.delegations.approveAndSubmit(
            request: request,
            options: DelegationSubmitOptions(
                onProgress: { progress in
                    switch progress.step {
                    case .signing:
                        print("Signing \(progress.index + 1)/\(progress.total)")
                    case .submitted:
                        print("Submitted: \(progress.hash ?? "")")
                    }
                }
            )
        )

        // These are broadcast, not confirmed.
        print("Submitted hashes: \(result.hashes)")
    } catch DelegationsError.noTransactions {
        print("The approval response contained no transactions to submit.")
    } catch DelegationsError.invalidTransactionHash(let index, let chainId) {
        print("Signer returned an unusable hash for transaction \(index) on \(chainId)")
    } catch {
        print("Error approving and submitting delegation: \(error)")
    }
}

// Without options, using the signer Portal installed
Task {
    do {
        let request = ApproveDelegationRequest(
            chain: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
            token: "USDC",
            delegateAddress: "7smgSuU5mjP7QY5yWGdaTfgKn8hUWwvQgfvgcZB3HmJi",
            amount: "0.01"
        )

        let result = try await portal.delegations.approveAndSubmit(request: request)

        print("Submitted hashes: \(result.hashes)")
    } catch {
        print("Error approving and submitting delegation: \(error)")
    }
}
```

**Related Documentation**

* [Manage Token Delegations](../guide/delegations)
* [Token delegations](/resources/delegations)
