func MakeKeyRegTxn(account string, note []byte, params types.SuggestedParams, voteKey, selectionKey string, voteFirst, voteLast, voteKeyDilution uint64) (types.Transaction, error) {
	accountAddr, err := types.DecodeAddress(account)
	if err != nil {
		return types.Transaction{}, err
	}
	if len(params.GenesisHash) == 0 {
		return types.Transaction{}, fmt.Errorf("key registration transaction must contain a genesisHash")
	}
	var gh types.Digest
	copy(gh[:], params.GenesisHash)
	votePKBytes, err := byte32FromBase64(voteKey)
	if err != nil {
		return types.Transaction{}, err
	}
	selectionPKBytes, err := byte32FromBase64(selectionKey)
	if err != nil {
		return types.Transaction{}, err
	}
	tx := types.Transaction{
		Type: types.KeyRegistrationTx,
		Header: types.Header{
			Sender:      accountAddr,
			Fee:         params.Fee,
			FirstValid:  params.FirstRoundValid,
			LastValid:   params.LastRoundValid,
			Note:        note,
			GenesisHash: gh,
			GenesisID:   params.GenesisID,
		},
		KeyregTxnFields: types.KeyregTxnFields{
			VotePK:          types.VotePK(votePKBytes),
			SelectionPK:     types.VRFPK(selectionPKBytes),
			VoteFirst:       types.Round(voteFirst),
			VoteLast:        types.Round(voteLast),
			VoteKeyDilution: voteKeyDilution,
		},
	}
	return setFee(tx, params)
}
MakeKeyRegTxn constructs a keyreg transaction using the passed parameters.
- account is a checksummed, human-readable address for which we register the given participation key.
- note is a byte array
- params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period
KeyReg parameters:
- votePK is a base64-encoded string corresponding to the root participation public key
- selectionKey is a base64-encoded string corresponding to the vrf public key
- voteFirst is the first round this participation key is valid
- voteLast is the last round this participation key is valid
- voteKeyDilution is the dilution for the 2-level participation key
package future
import (
	"encoding/base64"
	"fmt"
	"github.com/algorand/go-algorand-sdk/transaction"
	"github.com/algorand/go-algorand-sdk/types"
)
const MinTxnFee = transaction.MinTxnFee
func setFee(tx types.Transaction, params types.SuggestedParams) (types.Transaction, error) {
	if !params.FlatFee {
		eSize, err := transaction.EstimateSize(tx)
		if err != nil {
			return types.Transaction{}, err
		}
		tx.Fee = types.MicroAlgos(eSize * uint64(params.Fee))
		if tx.Fee < MinTxnFee {
			tx.Fee = MinTxnFee
		}
	} else {
		tx.Fee = params.Fee
	}
	return tx, nil
}
func MakePaymentTxn(from, to string, amount uint64, note []byte, closeRemainderTo string, params types.SuggestedParams) (types.Transaction, error) {
	fromAddr, err := types.DecodeAddress(from)
	if err != nil {
		return types.Transaction{}, err
	}
	toAddr, err := types.DecodeAddress(to)
	if err != nil {
		return types.Transaction{}, err
	}
	var closeRemainderToAddr types.Address
	if closeRemainderTo != "" {
		closeRemainderToAddr, err = types.DecodeAddress(closeRemainderTo)
		if err != nil {
			return types.Transaction{}, err
		}
	}
	if len(params.GenesisHash) == 0 {
		return types.Transaction{}, fmt.Errorf("payment transaction must contain a genesisHash")
	}
	var gh types.Digest
	copy(gh[:], params.GenesisHash)
	tx := types.Transaction{
		Type: types.PaymentTx,
		Header: types.Header{
			Sender:      fromAddr,
			Fee:         params.Fee,
			FirstValid:  params.FirstRoundValid,
			LastValid:   params.LastRoundValid,
			Note:        note,
			GenesisID:   params.GenesisID,
			GenesisHash: gh,
		},
		PaymentTxnFields: types.PaymentTxnFields{
			Receiver:         toAddr,
			Amount:           types.MicroAlgos(amount),
			CloseRemainderTo: closeRemainderToAddr,
		},
	}
	return setFee(tx, params)
}