onmyway133 / blog

🍁 What you don't know is what you haven't learned
https://onmyway133.com/
MIT License
669 stars 33 forks source link

How to calculate Solana transaction fee #866

Open onmyway133 opened 2 years ago

onmyway133 commented 2 years ago

A simple way is to use a fixed fee of 0.000005

For example from https://solscan.io/tx/5DkApvwTYuMqCiA94MhUVKJoLn8MGma9gAWXhreRJKqAs395P5CqEK3R84m3MWjcTKMem53XcLwYErGkaJAbQC2h?cluster=testnet

And call some exchange API, like Coingecko https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd and show the price in USD

{
  "solana": {
    "usd": 114.13
  }
}