add build transaction to send for address with code
@@ -307,7 +307,28 @@ func (t *Transactions) SendForAddressWithCode(
signer := project.AccountFromAddressAndKey(address, privateKey)
- tx := project.NewTransaction()
+ latestBlock, err := t.gateway.GetLatestBlock()
+ if err != nil {
+ return nil, nil, fmt.Errorf("failed to get latest sealed block: %w", err)
+ }
+
+ proposerAccount, err := t.gateway.GetAccount(address)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ tx := project.NewTransaction().
+ SetPayer(address).
+ SetProposer(proposerAccount, 0).
+ AddAuthorizers([]flow.Address{address}).
+ SetDefaultGasLimit().
+ SetBlockReference(latestBlock)
+
+ err = tx.SetScriptWithArgs(code, args, argsJSON)
+ if err != nil {
+ return nil, nil, err
+ }
+
err = tx.SetSigner(signer)
if err != nil {
return nil, nil, err
