Skip to content

Commit 8416384

Browse files
committed
Update examples to be compatible with new emulator
1 parent 3bdeddc commit 8416384

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

examples/create_account/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ func CreateAccountDemo() {
5757
createAccountTx := flow.NewTransaction().
5858
SetScript(createAccountScript).
5959
SetProposalKey(serviceAcctAddr, serviceAcctKey.ID, serviceAcctKey.SequenceNumber).
60-
SetPayer(serviceAcctAddr)
60+
SetPayer(serviceAcctAddr).
61+
AddAuthorizer(serviceAcctAddr)
6162

6263
// Sign the transaction with the service account, which already exists
6364
// All new accounts must be created by an existing account

examples/deploy_contract/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ func DeployContractDemo() {
6161
createAccountTx := flow.NewTransaction().
6262
SetScript(createAccountScript).
6363
SetProposalKey(serviceAcctAddr, serviceAcctKey.ID, serviceAcctKey.SequenceNumber).
64-
SetPayer(serviceAcctAddr)
64+
SetPayer(serviceAcctAddr).
65+
AddAuthorizer(serviceAcctAddr)
6566

6667
err = createAccountTx.SignEnvelope(serviceAcctAddr, serviceAcctKey.ID, serviceSigner)
6768
examples.Handle(err)
@@ -93,7 +94,8 @@ func DeployContractDemo() {
9394
deployContractTx := flow.NewTransaction().
9495
SetScript(deployScript).
9596
SetProposalKey(myAddress, myAcctKey.ID, myAcctKey.SequenceNumber).
96-
SetPayer(myAddress)
97+
SetPayer(myAddress).
98+
AddAuthorizer(myAddress)
9799

98100
err = deployContractTx.SignEnvelope(
99101
myAddress,

examples/examples.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func ServiceAccount(flowClient *client.Client) (flow.Address, *flow.AccountKey,
4646
privateKey, _ := crypto.GeneratePrivateKey(crypto.ECDSA_P256, []byte(defaultServiceKeySeed))
4747

4848
// Service address is the first generated account address
49-
addr := flow.ServiceAddress(flow.Mainnet)
49+
addr := flow.ServiceAddress(flow.Emulator)
5050

5151
acc, err := flowClient.GetAccount(context.Background(), addr)
5252
Handle(err)
@@ -110,7 +110,8 @@ func CreateAccount(flowClient *client.Client, publicKeys []*flow.AccountKey, cod
110110
createAccountTx := flow.NewTransaction().
111111
SetScript(createAccountScript).
112112
SetProposalKey(serviceAcctAddr, serviceAcctKey.ID, serviceAcctKey.SequenceNumber).
113-
SetPayer(serviceAcctAddr)
113+
SetPayer(serviceAcctAddr).
114+
AddAuthorizer(serviceAcctAddr)
114115

115116
err = createAccountTx.SignEnvelope(serviceAcctAddr, serviceAcctKey.ID, serviceSigner)
116117
Handle(err)

0 commit comments

Comments
 (0)