add transaction cost example
-package get_transaction_cost
+package main
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/hashgraph/hedera-sdk-go"
+)
+
+func main() {
+ operatorAccountID, err := hedera.AccountIDFromString(os.Getenv("OPERATOR_ID"))
+ if err != nil {
+ panic(err)
+ }
+
+ operatorPrivateKey, err := hedera.Ed25519PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
+ if err != nil {
+ panic(err)
+ }
+
+ newKey, err := hedera.GenerateEd25519PrivateKey()
+ if err != nil {
+ panic(err)
+ }
+
+ client := hedera.ClientForTestnet().
+ SetOperator(operatorAccountID, operatorPrivateKey)
+
+ transaction := hedera.NewAccountCreateTransaction().
+ SetKey(newKey.PublicKey()).
+ SetTransactionMemo("go sdk example create_account/main.go")
+
+ txCost, err := transaction.Cost(client)
+
+ if err != nil {
+ panic(err)
+ }
+
+ fmt.Printf("Estimated txCost to be applied is %v\n", txCost)
+
+ transactionID, err := transaction.
+ SetMaxTransactionFee(txCost).
+ Execute(client)
+
+ if err != nil {
+ panic(err)
+ }
+
+ transactionReceipt, err := transactionID.GetReceipt(client)
+
+ if err != nil {
+ panic(err)
+ }
+
+ newAccountID := transactionReceipt.GetAccountID()
+
+ fmt.Printf("succesfully created account %v\n", newAccountID)
+}
