|
| 1 | +--- |
| 2 | +title: Build a Transaction with the Flow CLI |
| 3 | +sidebar_title: Build a Transaction |
| 4 | +description: How to build a Flow transaction from the command line |
| 5 | +--- |
| 6 | + |
| 7 | +The Flow CLI provides a command to build a transactions with options to specify |
| 8 | +authorizer accounts, payer account and proposer account. |
| 9 | + |
| 10 | +The `build` command doesn't produce any signatures and instead |
| 11 | +is designed to be used with the `sign` and `send-signed` commands. |
| 12 | + |
| 13 | +Use this functionality in the following order: |
| 14 | +1. Use this command (`build`) to build the transaction. |
| 15 | +2. Use the `sign` command to sign with all accounts specified in the build process. |
| 16 | +3. Use `send-signed` command to submit the signed transaction to the Flow network. |
| 17 | + |
| 18 | +```shell |
| 19 | +flow transactions build <code filename> |
| 20 | +``` |
| 21 | + |
| 22 | +## Example Usage |
| 23 | + |
| 24 | +```shell |
| 25 | +> flow transactions build ./transaction.cdc \ |
| 26 | + --signer alice \ |
| 27 | + --proposer bob \ |
| 28 | + --payer charlie \ |
| 29 | + --arg "String:Meow" \ |
| 30 | + --filter payload --save built.rlp |
| 31 | + |
| 32 | +ID e8c0a69952fbe50a66703985e220307c8d44b8fa36c76cbca03f8c43d0167847 |
| 33 | +Payer e03daebed8ca0615 |
| 34 | +Authorizers [f3fcd2c1a78f5eee] |
| 35 | + |
| 36 | +Proposal Key: |
| 37 | + Address 179b6b1cb6755e31 |
| 38 | + Index 0 |
| 39 | + Sequence 1 |
| 40 | + |
| 41 | +No Payload Signatures |
| 42 | + |
| 43 | +No Envelope Signatures |
| 44 | + |
| 45 | + |
| 46 | +Arguments (1): |
| 47 | + - Argument 0: {"type":"String","value":"Meow"} |
| 48 | + |
| 49 | + |
| 50 | +Code |
| 51 | + |
| 52 | +transaction(greeting: String) { |
| 53 | + let guest: Address |
| 54 | + |
| 55 | + prepare(authorizer: AuthAccount) { |
| 56 | + self.guest = authorizer.address |
| 57 | + } |
| 58 | + |
| 59 | + execute { |
| 60 | + log(greeting.concat(",").concat(self.guest.toString())) |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | + |
| 65 | +Payload: |
| 66 | +f9013df90138b8d17472616e...73616374696f6e286eeec0c0 |
| 67 | +``` |
| 68 | + |
| 69 | +## Arguments |
| 70 | + |
| 71 | +### Code Filename |
| 72 | + |
| 73 | +- Name: `filename` |
| 74 | +- Valid inputs: Any filename and path valid on the system. |
| 75 | + |
| 76 | +The first argument is a path to a Cadence file containing the |
| 77 | +transaction to be executed. |
| 78 | + |
| 79 | + |
| 80 | +## Flags |
| 81 | + |
| 82 | + |
| 83 | +### Payer |
| 84 | + |
| 85 | +- Flag: `--payer` |
| 86 | +- Valid Inputs: Flow address or account name from configuration. |
| 87 | +- Default: service account |
| 88 | + |
| 89 | +Specify account address that will be paying for the transaction. |
| 90 | +Read more about payers [here](https://docs.onflow.org/concepts/accounts-and-keys/). |
| 91 | + |
| 92 | +### Proposer |
| 93 | + |
| 94 | +- Flag: `--proposer` |
| 95 | +- Valid inputs: Flow address or account name from configuration. |
| 96 | +- Default: service account |
| 97 | + |
| 98 | +Specify a name of the account that is proposing the transaction. |
| 99 | +Account must be defined in flow configuration. |
| 100 | + |
| 101 | +### Proposer Key Index |
| 102 | + |
| 103 | +- Flag: `--proposer-key-index` |
| 104 | +- Valid inputs: number of existing key index |
| 105 | +- Default: 0 |
| 106 | + |
| 107 | +Specify key index for the proposer account. |
| 108 | + |
| 109 | +### Authorizer |
| 110 | + |
| 111 | +- Flag: `--authorizer` |
| 112 | +- Valid Inputs: Flow address or account name from configuration. |
| 113 | +- Default: service account |
| 114 | + |
| 115 | +Additional authorizer addresses to add to the transaction. |
| 116 | +Read more about authorizers [here](https://docs.onflow.org/concepts/accounts-and-keys/). |
| 117 | + |
| 118 | +### Host |
| 119 | + |
| 120 | +- Flag: `--host` |
| 121 | +- Valid inputs: an IP address or hostname. |
| 122 | +- Default: `127.0.0.1:3569` (Flow Emulator) |
| 123 | + |
| 124 | +Specify the hostname of the Access API that will be |
| 125 | +used to execute the commands. |
| 126 | + |
| 127 | +### Network |
| 128 | + |
| 129 | +- Flag: `--network` |
| 130 | +- Short Flag: `-n` |
| 131 | +- Valid inputs: the name of a network defined in the configuration (`flow.json`) |
| 132 | +- Default: `emulator` |
| 133 | + |
| 134 | +Specify which network you want the command to use for execution. |
| 135 | + |
| 136 | +### Filter |
| 137 | + |
| 138 | +- Flag: `--filter` |
| 139 | +- Short Flag: `-x` |
| 140 | +- Valid inputs: case-sensitive name of the result property. |
| 141 | + |
| 142 | +Specify any property name from the result you want to return as the only value. |
| 143 | + |
| 144 | +### Output |
| 145 | + |
| 146 | +- Flag: `--output` |
| 147 | +- Short Flag: `-o` |
| 148 | +- Valid inputs: `json`, `inline` |
| 149 | + |
| 150 | +Specify in which format you want to display the result. |
| 151 | + |
| 152 | +### Save |
| 153 | + |
| 154 | +- Flag: `--save` |
| 155 | +- Short Flag: `-s` |
| 156 | +- Valid inputs: valid filename |
| 157 | + |
| 158 | +Specify the filename where you want the result to be saved. |
| 159 | + |
| 160 | +### Log |
| 161 | + |
| 162 | +- Flag: `--log` |
| 163 | +- Short Flag: `-l` |
| 164 | +- Valid inputs: `none`, `error`, `debug` |
| 165 | +- Default: `info` |
| 166 | + |
| 167 | +Specify the log level. Control how much output you want to see while command execution. |
| 168 | + |
| 169 | +### Configuration |
| 170 | + |
| 171 | +- Flag: `--config-path` |
| 172 | +- Short Flag: `-f` |
| 173 | +- Valid inputs: valid filename |
| 174 | + |
| 175 | +Specify a filename for the configuration files, you can provide multiple configuration |
| 176 | +files by using `-f` flag multiple times. |
| 177 | + |
| 178 | + |
| 179 | + |
0 commit comments