public func revokeAndSubmit(
request: RevokeDelegationRequest,
options: DelegationSubmitOptions
) async throws -> DelegationSubmitResult
// Convenience overload, using the signer Portal already installed for you
public func revokeAndSubmit(
request: RevokeDelegationRequest
) async throws -> DelegationSubmitResult
revoke and signing the returned transactions yourself.
revokeAndSubmit 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 revocation can still revert, and the delegation may still be active when this call returns. Poll getStatus before telling a user their delegation is gone.| Parameter | Type | Required | Description |
|---|---|---|---|
request | RevokeDelegationRequest | Yes | The revocation to build and submit. |
options | DelegationSubmitOptions | No | Per-call signer override and progress callback. Omit the argument entirely to use the convenience overload. |
RevokeDelegationRequest:
| 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 whose spending permission is being removed. |
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. |
DelegationSubmitResult containing:
| Field | Type | Description |
|---|---|---|
hashes | [String] | One hash per broadcast transaction, in submission order. Submitted, not confirmed. |
| 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 revoke 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 revocation failed. |
import PortalSwift
Task {
do {
let request = RevokeDelegationRequest(
chain: "eip155:11155111",
token: "USDC",
delegateAddress: "0xa944e86eb36f039becd1843132347eb5b8501562"
)
let result = try await portal.delegations.revokeAndSubmit(request: request)
// These are broadcast, not confirmed.
print("Revoke submitted: \(result.hashes)")
} catch DelegationsError.noTransactions {
print("The revoke response contained no transactions to submit.")
} catch {
print("Error revoking delegation: \(error)")
}
}
// With progress reporting
Task {
do {
let request = RevokeDelegationRequest(
chain: "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
token: "USDC",
delegateAddress: "7smgSuU5mjP7QY5yWGdaTfgKn8hUWwvQgfvgcZB3HmJi"
)
let result = try await portal.delegations.revokeAndSubmit(
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 ?? "")")
}
}
)
)
print("Revoke submitted: \(result.hashes)")
} catch DelegationsError.invalidTransactionHash(let index, let chainId) {
print("Signer returned an unusable hash for transaction \(index) on \(chainId)")
} catch {
print("Error revoking delegation: \(error)")
}
}