Comments (7)
Where did you get uusd gas price for 2?
from terra.js.
I'm curious about this too. I see other projects hardcoding gas prices (including terra.js which hardcodes default uluna gas prices). For example, it seems common to hardcode the uusd gas price to 0.15.
I've been doing something like this with success:
const stdTx = new StdTx([msg], new StdFee(0), [])
const fee = await terraClient.tx.estimateFee(stdTx, { gasPrices: { uusd: 0.15 } });
But that's including a hardcoded uusd gas price. That successfully calculates the stability fee and total gas, though, and ultimately works (at least on localterra and tequila), but is that the "correct" way to calculate fees? Is there a better way to estimate the gas price/ask the node for an acceptable gas price?
from terra.js.
@jimryan There are several correct ways to put fees
Given that the recommended gas prices (could be queried from https://fcd.terra.dev/v1/txs/gas_prices for the mainnet) does not change often, I personally prefer to use static StdFee
when I create predictable transactions. By the meaning of predictable is the gas
of the transaction doesn't change much by variables. I prefer this way to minimize network round trips.
In detail, when you call the create
function without the fee
parameter it automatically calls estimateFee
function with default gas prices which doesn't have other gas prices than "uluna" which is not what you probably want.
If you want it to estimate fee every time when you create the StdSignMsg
put recommended gasPrices (and feeDenoms) when you either create the LCDClient
object or create StdSignMsg
from terra.js.
@hanjukim Thanks! I ended up configuring the client with a hardcoded uusd
gas price, like this:
new LCDClient({
URL: network.lcdURL,
chainID: network.chainID,
gasPrices: network.gasPrices
});
Where network.gasPrices
is: { uusd: 0.15 }
.
Then I estimateFee
manually (so we can perform a balance check and it could be displayed to the user), and then post
the message and the fee to the Extension.
It sounds like the only way to improve on that would be to query the current uusd
gas price from the /gas_prices
endpoint, right?
from terra.js.
If I not specify gasPrices
in LCD client for uusd
so default for tequila-4 is just {uluna: 0.15}
I won't get valid fee from estimateFee
or create
for feeDenoms: ["uusd"]
right?
from terra.js.
Check out #107 I think this will resolve the issue?
from terra.js.
@hanjukim Thanks! I ended up configuring the client with a hardcoded
uusd
gas price, like this:new LCDClient({ URL: network.lcdURL, chainID: network.chainID, gasPrices: network.gasPrices });Where
network.gasPrices
is:{ uusd: 0.15 }
.Then I
estimateFee
manually (so we can perform a balance check and it could be displayed to the user), and thenpost
the message and the fee to the Extension.It sounds like the only way to improve on that would be to query the current
uusd
gas price from the/gas_prices
endpoint, right?
Can you show me the way you estimate fee? I'm trying with the method, but I'm getting the following error:
Possible Unhandled Promise Rejection (id: 18):
TypeError: Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
at TxBody.toProto (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:270293:33)
at Tx.toProto (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:270200:25)
at Tx.toBytes (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:270209:109)
at TxAPI.encode (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:316578:29)
at TxAPI.<anonymous> (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:316544:32)
at step (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:316312:21)
at Object.next (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:316242:16)
at /Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:316214:69
at tryCallTwo (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:31031:7)
at doResolve (/Users/user/Desktop/Project_2/Project/.vscode/.react/index.bundle:31195:15)
The code I'm using:
const signerData = [{sequenceNumber: wallet.key.sequenceNumber,
publicKey: wallet.key.publicKey}]
// estimate the fee
const fee = await this.terra.tx.estimateFee(
signerData,
msgs,
{gasPrices: { uusd: 0.15 }}
);
This is the version of terra.js I have:
"@terra-money/terra.js": "^3.0.0",
from terra.js.
Related Issues (20)
- Same API, different return results HOT 4
- CreateTxFailed: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. HOT 2
- Tx.unpackAny doesn't consider isClassic HOT 2
- TxApi.decode() has bug. HOT 1
- TxApi has wrong path on search function HOT 5
- wasm endpoint HOT 2
- Wrong codec type used in commission withdrawal
- tx.search === LCDResponseError: Status 403 - None HOT 1
- Following Terra.js Smart Contract section. HOT 7
- MsgTransfer is lacking a toJson() function
- lsd.wasm.contractQuery crashed with "Error parsing into type basset::reward::QueryMsg: unknown variant `token_info`..."
- Question: phoenix-1 uluna gas prices reference
- Tx.unpackAny fails on /cosmwasm.wasm.v1.MsgMigrateContract
- release 3.1.8
- Error when querying CW20 token balance using terra.js
- Error executing terra.tx.estimateFee
- Error getting txInfosByHeight with MsgVote HOT 1
- Example for upload code fails
- ailed to execute message; mwithdraw ustc failed ,essage index: 0: dispatch: submessages: Generic error: Querier system error: Unsupported query type: unknown terra query variant:
- Unable to convert StakeAuthorisation fromAmino
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terra.js.