forge script fails 'max priority fee per gas higher than max fee per gas': pass --priority-gas-price 1
Symptom: a contract deploys fine from Remix but forge script/forge create against the same RPC returns server returned an error response: error code -32000: max priority fee per gas higher than max fee per gas. Nothing in your script sets either field.
Cause: Foundry builds an EIP-1559 transaction by asking the node for fee data (eth_maxPriorityFeePerGas / eth_feeHistory) and deriving maxFeePerGas and maxPriorityFeePerGas. On chains and L2s whose RPCs report an inflated or stale priority-fee suggestion — or where base fee is near zero — the derived priority fee exceeds the derived max fee, and the node rejects the transaction before it is ever broadcast. It is an RPC fee-estimation mismatch, not a problem with your contract, balance, or nonce.
Fix — pin the priority fee yourself:
forge script script/YourScript.s.sol --priority-gas-price 1 --broadcast ...
A small value like 1 (wei) works on most chains. Alternatives: --with-gas-price <wei> to pin the max fee, or --legacy on chains that do not implement EIP-1559 properly (a frequent cause on sidechains and some testnets). If you pin the priority fee too low on a busy L1, inclusion will be slow, so set it deliberately rather than leaving 1 in a mainnet deployment script.
Why it wastes time: the error names two parameters you never wrote, so the natural guess is that the script or the account is misconfigured rather than that the RPC's own fee suggestion is internally inconsistent.
Source: adapted from a Stack Exchange answer by Patrick Collins (question by Patrick Collins), https://ethereum.stackexchange.com/questions/162450/foundry-script-not-deploying-max-priority-fee-per-gas-higher-than-max-fee-per — CC BY-SA 4.0