Skip to content

Commit b60e9a5

Browse files
feat: use min_configured_gas_price obtained from rpc/v3/transactions/estimate_gas_price endpoint as default gas_unit_price
1 parent f87d125 commit b60e9a5

5 files changed

Lines changed: 12 additions & 9 deletions

File tree

examples/automation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
async def main():
1717
supra_client_config = SupraClientConfig(
1818
expiration_ttl=300,
19-
gas_unit_price=100,
19+
gas_unit_price=100_000,
2020
max_gas_amount=100_000,
2121
)
2222
supra_client = SupraClient(RPC_NODE_URL, supra_client_config)

examples/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
SUPRA_CORE_PATH = os.getenv("SUPRA_CORE_PATH", os.path.abspath("../aptos-core"))
88
FAUCET_URL = os.getenv(
99
"SUPRA_FAUCET_URL",
10-
"http://localhost:27001/",
10+
"https://rpc-testnet.supra.com/",
1111
)
12-
RPC_NODE_URL = os.getenv("SUPRA_RPC_NODE_URL", "http://localhost:27001/")
12+
RPC_NODE_URL = os.getenv("SUPRA_RPC_NODE_URL", "https://rpc-testnet.supra.com/")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "uv_build"
44

55
[project]
66
name = "supra-sdk"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "A Python SDK for seamless interaction with the Supra-L1 network, supporting Move-VM operations and transactions."
99
requires-python = ">=3.12"
1010
license = { file = "LICENSE" }

supra_sdk/clients/rest/supra_client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class TransactionConfig:
4848
Attributes:
4949
expiration_ttl (int): Time-to-live, in seconds, before a transaction expires and is rejected by the network.
5050
Defaults to 600.
51-
gas_unit_price (int): Price per unit of gas used to execute the transaction. Defaults to 100.
51+
gas_unit_price (int): Price per unit of gas used to execute the transaction. Defaults to
52+
`min_configured_gas_price` obtained from `rpc/v3/transactions/estimate_gas_price` endpoint.
5253
max_gas_amount (int): Maximum number of gas units allowed per transaction. Defaults to 500,000.
5354
transaction_wait_time_in_seconds (int): Number of seconds to wait for a transaction to be executed before timing
5455
out. Defaults to 20.
@@ -60,7 +61,7 @@ class TransactionConfig:
6061
"""
6162

6263
expiration_ttl: int = 600
63-
gas_unit_price: int = 100
64+
gas_unit_price: int | None = None
6465
max_gas_amount: int = 500_000
6566
transaction_wait_time_in_seconds: int = 20
6667
polling_wait_time_in_seconds: int = 1
@@ -98,7 +99,8 @@ class SupraClient(
9899
99100
Attributes:
100101
_chain_id (int | None): The chain-id of the network.
101-
api_client (supra_sdk.clients.api_client.ApiClient): Inherited from `RestClient`. Used to send HTTP requests to the Supra RPC node.
102+
api_client (supra_sdk.clients.api_client.ApiClient): Inherited from `RestClient`. Used to send HTTP requests to
103+
the Supra RPC node.
102104
103105
"""
104106

@@ -305,7 +307,8 @@ async def create_raw_transaction(
305307
sequence_number,
306308
transaction_payload,
307309
self.transaction_config.max_gas_amount,
308-
self.transaction_config.gas_unit_price,
310+
self.transaction_config.gas_unit_price
311+
or (await self.estimate_gas_price())["min_configured_gas_price"],
309312
int(time.time()) + self.transaction_config.expiration_ttl,
310313
await self.chain_id(),
311314
)

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)