Help us shape the future of Go! Take the 2026 Go Developer Survey

send

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:     "send",
	Short:   "Send a transaction",
	Example: `flow transactions send --code=tx.cdc --args="[{\"type\": \"String\", \"value\": \"Hello, Cadence\"}]"`,
	Run: func(cmd *cobra.Command, args []string) {
		projectConf := cli.LoadConfig()

		signerAccount := projectConf.Accounts[conf.Signer]

		if signerAccount == nil && conf.Signer == "service" {
			signerAccount = projectConf.Accounts["emulator-account"]
		}

		validateKeyPreReq(signerAccount)
		var (
			code []byte
			err  error
		)

		if conf.Code != "" {
			code, err = ioutil.ReadFile(conf.Code)
			if err != nil {
				cli.Exitf(1, "Failed to read transaction script from %s", conf.Code)
			}
		}

		tx := flow.
			NewTransaction().
			SetScript(code).
			AddAuthorizer(signerAccount.Address)

		if conf.Args != "" {
			transactionArguments, err := cli.ParseArguments(conf.Args)
			if err != nil {
				cli.Exitf(1, "Invalid arguments passed: %s", conf.Args)
			}

			for _, arg := range transactionArguments {
				err := tx.AddArgument(arg)

				if err != nil {
					cli.Exitf(1, "Failed to add %s argument to a transaction ", conf.Code)
				}
			}
		}

		cli.SendTransaction(projectConf.HostWithOverride(conf.Host), signerAccount, tx, conf.Results)
	},
}

Functions

This section is empty.

Types

type Config

type Config struct {
	Args    string `default:"" flag:"args" info:"arguments in JSON-Cadence format"`
	Code    string `flag:"code,c" info:"path to Cadence file"`
	Host    string `flag:"host" info:"Flow Access API host address"`
	Signer  string `default:"service" flag:"signer,s"`
	Results bool   `default:"false" flag:"results" info:"Display the results of the transaction"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL