Skip to content

Commit

Permalink
examples now load the operator id from the OPERATOR_ID environment va…
Browse files Browse the repository at this point in the history
…riable
  • Loading branch information
QuestofIranon committed Jan 9, 2020
1 parent a1f8d65 commit fe42e16
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion examples/create_account/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ func main() {
})

operatorPrivateKey, err := hedera.Ed25519PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
if err != nil {
panic(err)
}

operatorAccountID, err := hedera.AccountIDFromString(os.Getenv("OPERATOR_ID"))
if err != nil {
panic(err)
}

client.SetOperator(
// Operator Account ID
hedera.AccountID{Account: 2},
operatorAccountID,
// Operator Private Key
operatorPrivateKey,
)
Expand Down
6 changes: 5 additions & 1 deletion examples/create_file/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ func main() {
})

operatorPrivateKey, err := hedera.Ed25519PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
if err != nil {
panic(err)
}

operatorAccountID, err := hedera.AccountIDFromString(os.Getenv("OPERATOR_ID"))
if err != nil {
panic(err)
}

client.SetOperator(
// Operator Account ID
hedera.AccountID{Account: 2},
operatorAccountID,
// Operator Private Key
operatorPrivateKey,
)
Expand Down
8 changes: 6 additions & 2 deletions examples/get_account_balance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ func main() {
})

operatorPrivateKey, err := hedera.Ed25519PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
if err != nil {
panic(err)
}

operatorAccountID, err := hedera.AccountIDFromString(os.Getenv("OPERATOR_ID"))
if err != nil {
panic(err)
}

client.SetOperator(hedera.AccountID{Account: 2}, operatorPrivateKey)
client.SetOperator(operatorAccountID, operatorPrivateKey)

balance, err := hedera.NewAccountBalanceQuery().
SetAccountID(hedera.AccountID{Account: 2}).
SetAccountID(oepratorAccountID).
Execute(client)

if err != nil {
Expand Down

0 comments on commit fe42e16

Please sign in to comment.