PortalSwift module. It is not a method on Portal, so no wallet or client is required to call it.
The returned value is a lowercased UUID v4, which always meets Portal’s key rules (1–255 characters of A-Z a-z 0-9 . _ ~ -).
Pass the result to RequestOptions(idempotencyKey:) for eth_sendTransaction, sol_signAndSendTransaction or sol_signAndConfirmTransaction, or to SendAssetParams(idempotencyKey:) for sendAsset on EVM and Solana chains. Portal broadcasts a key at most once while it remembers the key (at least 24 hours after the request was last updated), so a retry with the same key within that time cannot send the same transaction twice.
Parameters
- None.
String: a lowercased UUID v4, for example"550e8400-e29b-41d4-a716-446655440000".
- Nothing. This function cannot fail.
PortalIdempotencyErrorIdholds the error IDs Portal returns, asPortalMpcError.id, when it rejects a request because of its key.PortalMpcError.isIdempotencyRejectionchecks for any of them, andPortalMpcError.isIdempotencyKeyReusedchecks forkeyReused.PortalIdempotencyErroris thrown by the SDK before anything is signed or sent:invalidKeyfor a key that breaks the rules above, andunsupportedTargetfor a key oneth_sendRawTransaction,sol_sendTransactionor a BitcoinsendAsset. The associated value describes the problem and never contains the key.
- Generate one key per operation, not per attempt. Reuse it only to retry the identical request.
- Portal remembers a key for at least 24 hours after the request was last updated, then removes it. Once the key is removed, the same key is treated as a new request, so check the chain before retrying an operation that is older than 24 hours.
- No rejection returns the original transaction hash. Check the chain before sending an operation again under a new key.