solana-developers / solana-cookbook

https://solanacookbook.com/
624 stars 344 forks source link

add: python example for calculating tx cost #348

Open GitBolt opened 2 years ago

vercel[bot] commented 2 years ago

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

Name Status Preview Updated
solana-cookbook ✅ Ready (Inspect) Visit Preview May 21, 2022 at 7:55AM (UTC)
GitBolt commented 2 years ago

I wasn't able to find documentation which covers the code in calc-tx-cost.en.ts and it's preview. Hence, I haven't added anything to the documentation for it's Python equivalent example.

GitBolt commented 2 years ago

@jacobcreech I've added the Python equivalent example for calc-tx-cost.en.ts, however in basic-transactions.md, it seems like there is no place where it's being used. calc-tx-est-fees-for-message.en and calc-tx-est-fees.en.ts are being used however calc-tx-cost.en.ts isn't there, so I'm a little unsure where I'm supposed to add the Python example.

jacobcreech commented 2 years ago

You could just add a component for SolanaCodeGroupItem in the list like everywhere else that has the type python

GitBolt commented 2 years ago

@jacobcreech Done! Please review

jacobcreech commented 2 years ago

Hey @GitBolt, that python example is actually not the same as the Typescript example. Not only that, but it will be out of date soon as fees change.

Make sure you use the getFeeForMessage RPC API call with the Transaction Message to get an accurate fee calculation. You can update with the python example and set it here

GitBolt commented 2 years ago

@jacobcreech Yeah that's why I was confused since there was no example in the docs for the TypeScript equivalent as I asked earlier. About the out of date part, Solana.py hasn't implemented the getFeeForMessage method yet, however I've built a library which does have it, is it okay if I use it? You can check it out here - Solathon

jacobcreech commented 2 years ago

I'd probably contribute the new RPC call and then update. The current SDK is very open to contributions