-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (34 loc) · 1.07 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"hedera-dev/initializers"
"hedera-dev/models"
"hedera-dev/queries"
"log"
"github.com/hashgraph/hedera-sdk-go/v2"
)
var (
oha *models.HederaAcount
hc *hedera.Client
recipientAccountId hedera.AccountID
)
func init() {
// init env vars
initializers.LoadEnvVars();
// construct Operator HederaAcount
oha = initializers.InitHederaAccount()
// init HederaClient
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() {
// 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")
}