Skip to content

feat(iota): gas related improvements to ptb cmd #7958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 25, 2025

Conversation

Thoralf-M
Copy link
Member

@Thoralf-M Thoralf-M commented Jul 24, 2025

Description of change

Fixes #7834
Also fixes #7959

Adding support to iota client ptb to --gas-price, --gas-sponsor and the ability to supply multiple object IDs to --gas-coin.

When providing gas coins to a dry-run, there could be some confusion, because the gas budget of the gas coin can't be used to split from the gas coin, so this fails (unless one has more than what one wants to split from the gas coin + 50 IOTA/max gas budget):

ACTIVE_ADDRESS=$(iota client active-address)
read COIN_OBJECT_ID_1 COIN_OBJECT_ID_2 < <(iota client gas --json | jq -r '[.[0].gasCoinId, .[1].gasCoinId] | @sh' | tr -d \')
AMOUNT=1000

iota client ptb \
  --split-coins gas "[$AMOUNT]" \
  --assign coins \
  --transfer-objects "[coins]" @$ACTIVE_ADDRESS \
  --gas-coin @$COIN_OBJECT_ID_1 @$COIN_OBJECT_ID_2 \
  --dry-run
[warn] Gas budget is equal to the total gas balance of the provided gas coins: 48173137999. Manually provide a lower gas budget if you need to split a coin from the gas coin.
Dry run completed, execution status: failure due to InsufficientCoinBalance in command 0
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Dry Run Transaction Data                                                                                     │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                                   │
│ Gas Owner: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                                │
│ Gas Budget: 48173137999 NANOS                                                                                │
│ Gas Price: 1000 NANOS                                                                                        │
│ Gas Payment:                                                                                                 │
│  ┌──                                                                                                         │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                                    │
│  │ Version: 400525585                                                                                        │
│  │ Digest: 8FRWg9VFqZ2yE8XCTskL1evp1zj34Ypkd693xipxZWka                                                      │
│  └──  ┌──                                                                                                    │
│  │ ID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                                    │
│  │ Version: 400525585                                                                                        │
│  │ Digest: 9m8pZhZue47TZ7KoYK7mAdEB9TzENiZ7i1iCSDeKtc9D                                                      │
│  └──                                                                                                         │
│                                                                                                              │
│ Transaction Kind: Programmable                                                                               │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Input Objects                                                                                            │ │
│ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │
│ │ 0   Pure Arg: Type: u64, Value: "1000"                                                                   │ │
│ │ 1   Pure Arg: Type: address, Value: "0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215" │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭──────────────────────╮                                                                                     │
│ │ Commands             │                                                                                     │
│ ├──────────────────────┤                                                                                     │
│ │ 0  SplitCoins:       │                                                                                     │
│ │  ┌                   │                                                                                     │
│ │  │ Coin: GasCoin     │                                                                                     │
│ │  │ Amounts:          │                                                                                     │
│ │  │   Input  0        │                                                                                     │
│ │  └                   │                                                                                     │
│ │                      │                                                                                     │
│ │ 1  TransferObjects:  │                                                                                     │
│ │  ┌                   │                                                                                     │
│ │  │ Arguments:        │                                                                                     │
│ │  │   Result 0        │                                                                                     │
│ │  │ Address: Input  1 │                                                                                     │
│ │  └                   │                                                                                     │
│ ╰──────────────────────╯                                                                                     │
│                                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Effects                                                                               │
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Digest: EGTQsBUNCwFZoGtJfyd7Cjwi5KD4SnrzePnLg4Vqjy7Y                                              │
│ Status: Failure { error: "InsufficientCoinBalance in command 0" }                                 │
│ Executed Epoch: 249                                                                               │
│ Mutated Objects:                                                                                  │
│  ┌──                                                                                              │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                         │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ Version: 400525586                                                                             │
│  │ Digest: 9FiMKcYx9YS461HmnPYUPihcw6Zkx8piFFKigz1D3BWC                                           │
│  └──                                                                                              │
│ Deleted Objects:                                                                                  │
│  ┌──                                                                                              │
│  │ ID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                         │
│  │ Version: 400525586                                                                             │
│  │ Digest: 7gyGAp71YXQRoxmFBaHxofQXAipvgHyBKPyxmdSJxyvz                                           │
│  └──                                                                                              │
│ Gas Object:                                                                                       │
│  ┌──                                                                                              │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                         │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ Version: 400525586                                                                             │
│  │ Digest: 9FiMKcYx9YS461HmnPYUPihcw6Zkx8piFFKigz1D3BWC                                           │
│  └──                                                                                              │
│ Gas Cost Summary:                                                                                 │
│    Storage Cost: 980400 NANOS                                                                     │
│    Computation Cost: 1000000 NANOS                                                                │
│    Computation Cost Burned: 1000000 NANOS                                                         │
│    Storage Rebate: 1960800 NANOS                                                                  │
│    Non-refundable Storage Fee: 0 NANOS                                                            │
│                                                                                                   │
│ Transaction Dependencies:                                                                         │
│    7jDQMm6Wd1a8bUL7VzJuB5cc9E9UMMR4LdYDYXQAzsiU                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────╮
│ No transaction block events │
╰─────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Object Changes                                                                                   │
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Deleted Objects:                                                                                 │
│  ┌──                                                                                             │
│  │ ObjectID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                  │
│  │ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                    │
│  │ ObjectType: 0x2::coin::Coin<0x2::iota::IOTA>                                                  │
│  │ Version: 400525586                                                                            │
│  └──                                                                                             │
│ Mutated Objects:                                                                                 │
│  ┌──                                                                                             │
│  │ ObjectID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                  │
│  │ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                    │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 ) │
│  │ ObjectType: 0x2::coin::Coin<0x2::iota::IOTA>                                                  │
│  │ Version: 400525586                                                                            │
│  │ Digest: 9FiMKcYx9YS461HmnPYUPihcw6Zkx8piFFKigz1D3BWC                                          │
│  └──                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Balance Changes                                                                                   │
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│  ┌──                                                                                              │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ CoinType: 0x2::iota::IOTA                                                                      │
│  │ Amount: -19600                                                                                 │
│  └──                                                                                              │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
Dry run completed, execution status: failure due to InsufficientCoinBalance in command 0
Estimated gas cost (includes a small buffer): 2000000 NANOS

providing a manual lower gas budget makes the dry run work

ACTIVE_ADDRESS=$(iota client active-address)
read COIN_OBJECT_ID_1 COIN_OBJECT_ID_2 < <(iota client gas --json | jq -r '[.[0].gasCoinId, .[1].gasCoinId] | @sh' | tr -d \')
AMOUNT=1000

iota client ptb \
  --split-coins gas "[$AMOUNT]" \
  --assign coins \
  --transfer-objects "[coins]" @$ACTIVE_ADDRESS \
  --gas-coin @$COIN_OBJECT_ID_1 @$COIN_OBJECT_ID_2 \
  --gas-budget 2000000 \
  --dry-run
Dry run completed, execution status: success
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Dry Run Transaction Data                                                                                     │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                                   │
│ Gas Owner: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                                │
│ Gas Budget: 2000000 NANOS                                                                                    │
│ Gas Price: 1000 NANOS                                                                                        │
│ Gas Payment:                                                                                                 │
│  ┌──                                                                                                         │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                                    │
│  │ Version: 400525585                                                                                        │
│  │ Digest: 8FRWg9VFqZ2yE8XCTskL1evp1zj34Ypkd693xipxZWka                                                      │
│  └──  ┌──                                                                                                    │
│  │ ID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                                    │
│  │ Version: 400525585                                                                                        │
│  │ Digest: 9m8pZhZue47TZ7KoYK7mAdEB9TzENiZ7i1iCSDeKtc9D                                                      │
│  └──                                                                                                         │
│                                                                                                              │
│ Transaction Kind: Programmable                                                                               │
│ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │
│ │ Input Objects                                                                                            │ │
│ ├──────────────────────────────────────────────────────────────────────────────────────────────────────────┤ │
│ │ 0   Pure Arg: Type: u64, Value: "1000"                                                                   │ │
│ │ 1   Pure Arg: Type: address, Value: "0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215" │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │
│ ╭──────────────────────╮                                                                                     │
│ │ Commands             │                                                                                     │
│ ├──────────────────────┤                                                                                     │
│ │ 0  SplitCoins:       │                                                                                     │
│ │  ┌                   │                                                                                     │
│ │  │ Coin: GasCoin     │                                                                                     │
│ │  │ Amounts:          │                                                                                     │
│ │  │   Input  0        │                                                                                     │
│ │  └                   │                                                                                     │
│ │                      │                                                                                     │
│ │ 1  TransferObjects:  │                                                                                     │
│ │  ┌                   │                                                                                     │
│ │  │ Arguments:        │                                                                                     │
│ │  │   Result 0        │                                                                                     │
│ │  │ Address: Input  1 │                                                                                     │
│ │  └                   │                                                                                     │
│ ╰──────────────────────╯                                                                                     │
│                                                                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Transaction Effects                                                                               │
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Digest: DXbRV99DaStnoSL3HrBYCeYpkWseFbhJaWH8u7SbBbFK                                              │
│ Status: Success                                                                                   │
│ Executed Epoch: 249                                                                               │
│                                                                                                   │
│ Created Objects:                                                                                  │
│  ┌──                                                                                              │
│  │ ID: 0x7a3adc2620d7c326049758b3415e7720da7c6ed87a1681038e2775440f9cb8ad                         │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ Version: 400525586                                                                             │
│  │ Digest: 7ssAPwcmTvaYZe7pwVC7BSyNHQizsnUXd7Xyd1F3Swj2                                           │
│  └──                                                                                              │
│ Mutated Objects:                                                                                  │
│  ┌──                                                                                              │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                         │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ Version: 400525586                                                                             │
│  │ Digest: B5jHxHdkDrmju6VUPSNsETNY6z7vHVcGArghZxWU87eM                                           │
│  └──                                                                                              │
│ Deleted Objects:                                                                                  │
│  ┌──                                                                                              │
│  │ ID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                         │
│  │ Version: 400525586                                                                             │
│  │ Digest: 7gyGAp71YXQRoxmFBaHxofQXAipvgHyBKPyxmdSJxyvz                                           │
│  └──                                                                                              │
│ Gas Object:                                                                                       │
│  ┌──                                                                                              │
│  │ ID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                         │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ Version: 400525586                                                                             │
│  │ Digest: B5jHxHdkDrmju6VUPSNsETNY6z7vHVcGArghZxWU87eM                                           │
│  └──                                                                                              │
│ Gas Cost Summary:                                                                                 │
│    Storage Cost: 1960800 NANOS                                                                    │
│    Computation Cost: 1000000 NANOS                                                                │
│    Computation Cost Burned: 1000000 NANOS                                                         │
│    Storage Rebate: 1960800 NANOS                                                                  │
│    Non-refundable Storage Fee: 0 NANOS                                                            │
│                                                                                                   │
│ Transaction Dependencies:                                                                         │
│    7jDQMm6Wd1a8bUL7VzJuB5cc9E9UMMR4LdYDYXQAzsiU                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────╮
│ No transaction block events │
╰─────────────────────────────╯
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Object Changes                                                                                   │
├──────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Created Objects:                                                                                 │
│  ┌──                                                                                             │
│  │ ObjectID: 0x7a3adc2620d7c326049758b3415e7720da7c6ed87a1681038e2775440f9cb8ad                  │
│  │ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                    │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 ) │
│  │ ObjectType: 0x2::coin::Coin<0x2::iota::IOTA>                                                  │
│  │ Version: 400525586                                                                            │
│  │ Digest: 7ssAPwcmTvaYZe7pwVC7BSyNHQizsnUXd7Xyd1F3Swj2                                          │
│  └──                                                                                             │
│ Deleted Objects:                                                                                 │
│  ┌──                                                                                             │
│  │ ObjectID: 0x6449a56de7517bafeb9d4cd95788c59655c3ecec0a905b6fa6cb63f49ba28d11                  │
│  │ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                    │
│  │ ObjectType: 0x2::coin::Coin<0x2::iota::IOTA>                                                  │
│  │ Version: 400525586                                                                            │
│  └──                                                                                             │
│ Mutated Objects:                                                                                 │
│  ┌──                                                                                             │
│  │ ObjectID: 0x0b22c2ba14ddf181117012de88ffccd2158097ad94adf6f9ae353c2493f86eec                  │
│  │ Sender: 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215                    │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 ) │
│  │ ObjectType: 0x2::coin::Coin<0x2::iota::IOTA>                                                  │
│  │ Version: 400525586                                                                            │
│  │ Digest: B5jHxHdkDrmju6VUPSNsETNY6z7vHVcGArghZxWU87eM                                          │
│  └──                                                                                             │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Balance Changes                                                                                   │
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
│  ┌──                                                                                              │
│  │ Owner: Account Address ( 0x111111111504e9350e635d65cd38ccd2c029434c6a3a480d8947a9ba6a15b215 )  │
│  │ CoinType: 0x2::iota::IOTA                                                                      │
│  │ Amount: -1000000                                                                               │
│  └──                                                                                              │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
Dry run completed, execution status: success
Estimated gas cost (includes a small buffer): 2000000 NANOS

Links to any relevant issues

Fixes #7834

How the change has been tested

  • Basic tests (linting, compilation, formatting, unit/integration tests)
  • Patch-specific tests (correctness, functionality coverage)
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

Release Notes

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Added --gas-price and --gas-sponsor flags to iota client ptb. Also added support to accept multiple gas coins with --gas-coins
  • Rust SDK:
  • REST API:

Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

6 Skipped Deployments
Name Status Preview Comments Updated (UTC)
apps-backend ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am
apps-ui-kit ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am
iota-evm-bridge ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am
iota-multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am
rebased-explorer ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am
wallet-dashboard ⬜️ Ignored (Inspect) Visit Preview Jul 25, 2025 9:39am

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jul 24, 2025
@iota-ci iota-ci added dev-tools Issues related to the Developer Tools Team sc-platform Issues related to the Smart Contract Platform group. labels Jul 24, 2025
@Thoralf-M Thoralf-M marked this pull request as ready for review July 24, 2025 10:25
@Thoralf-M Thoralf-M requested review from a team as code owners July 24, 2025 10:25
Copy link
Contributor

✅ Vercel Preview Deployment is ready!

View Preview

Copy link
Contributor

✅ Vercel Preview Deployment is ready!

View Preview

Copy link
Contributor

✅ Vercel Preview Deployment is ready!

View Preview

@thibault-martinez
Copy link
Member

Failing test

Copy link
Contributor

✅ Vercel Preview Deployment is ready!

View Preview

@Alex6323
Copy link
Contributor

Alex6323 commented Jul 25, 2025

So this fixes #7959 as well, right? Can you add it to the description so it's linked?

Copy link
Contributor

✅ Vercel Preview Deployment is ready!

View Preview

@thibault-martinez thibault-martinez merged commit a4dd7fd into develop Jul 25, 2025
40 checks passed
@thibault-martinez thibault-martinez deleted the dev-tools/gas-related-improvements branch July 25, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-tools Issues related to the Developer Tools Team documentation Improvements or additions to documentation sc-platform Issues related to the Smart Contract Platform group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: --serialize-unsigned-transaction outputs twice upstream: gas-related improvements
7 participants