Skip to content

Conversation

@ertemann
Copy link

@ertemann ertemann commented Nov 18, 2025

Summary

Adds automatic gas price discovery for chains with dynamic feemarket modules (Osmosis EIP-1559 and Skip feemarket). Instead of manually setting static gas prices, CosmJS can now query current prices from the chain, preventing transaction failures from outdated pricing.

Changes

  • New feemarket.ts: Query dynamic gas prices from Osmosis EIP-1559 and Skip feemarket modules
  • Updated clients: SigningStargateClient and SigningCosmWasmClient now support DynamicGasPriceConfig
  • Refactoring: Extracted calculateFeeForTransaction() helper
  • Tests: Some unit tests and an end-to-end validation on Osmosis and Neutron testnets

Usage

const client = await SigningStargateClient.connectWithSigner(rpc, signer, {
  gasPrice: {
    denom: "uosmo",
    multiplier: 1.3,
    minGasPrice: GasPrice.fromString("0.0025uosmo"),
    maxGasPrice: GasPrice.fromString("0.1uosmo"),
  }
});

// Gas price queried automatically per transaction
await client.signAndBroadcast(address, messages, "auto");

Features

Graceful fallback to minGasPrice if feemarket query fails
Min/max constraint enforcement with configurable multiplier
backward compatible - existing code unchanged
Automatic chain detection for Osmosis variants

Inspired by Hermes relayer PR #4004.

@ertemann ertemann changed the title add dynamic gasfee pricing as an option through feemarket and osmosis… add dynamic gasfee pricing as a signing client option - Feemarket/Osmosis Nov 18, 2025

// Multiply by multiplier 18 fractional digits for Dec type
const fractionalDigits = minGasPrice.amount.fractionalDigits;
const adjustedGasPrice = multiplyDecimalByNumber(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a cleaner way to do this please advise


// Replace with your mnemonic or set MNEMONIC env var
// WARNING: Never commit real mnemonics to git!
const MNEMONIC =
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throwaway mnemonic for you to test with.

@@ -0,0 +1,278 @@
#!/usr/bin/env node
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a complete integration test to validate the PR, can be removed once merged

@ertemann ertemann marked this pull request as draft November 18, 2025 15:00
@ertemann ertemann marked this pull request as ready for review November 18, 2025 20:10
}
}

// Minimal protobuf type definitions matching cosmjs-types pattern
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or should this actually go into cosmjs/types? they refer to /feemarket module ofcourse and not base SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant