Skip to content

Commit

Permalink
update: updated main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
quiet-node committed Jun 13, 2023
1 parent 6041fe0 commit d83d204
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,45 @@ package main
import (
"hedera-dev/initializers"
"hedera-dev/models"
"hedera-dev/queries"
"log"

"github.com/hashgraph/hedera-sdk-go/v2"
)

var (
ha *models.HederaAcount
oha *models.HederaAcount
hc *hedera.Client
recipientAccountId hedera.AccountID
)

func init() {
// init env vars
initializers.LoadEnvVars();

// construct HederaAcount
ha = initializers.InitHederaAccount()
// construct Operator HederaAcount
oha = initializers.InitHederaAccount()

// init HederaClient
hc = initializers.InitHederaClientForTestnet(ha)
hc = initializers.InitHederaClientForTestnet(oha)

// init recipientAccountId
recipientAccountId, _ = hedera.AccountIDFromString("0.0.14303758") // "0.0.14303758" is a random accountID created by transactions.CreateNewAccount()

}

func main() {
log.Println(hc.GetOperatorAccountID())
log.Println(hc.GetOperatorPublicKey())


// create new account transaction
// transactions.CreateNewAccount(hc);

// transfer hbar transaction
// transactions.TransferHbar(oha.AccountId, recipientAccountId, hc)

// check balance query
opBal := queries.GetBalanceQuery(oha.AccountId, hc)
log.Println("Operator balance:", opBal.Hbars.AsTinybar(), "th")
reBal := queries.GetBalanceQuery(recipientAccountId, hc)
log.Println("Recipient balance:", reBal.Hbars.AsTinybar(), "th")

}

0 comments on commit d83d204

Please sign in to comment.