Update a Contract
Update an existing contract deployed to a Flow account using the Flow CLI.
_10flow accounts update-contract <filename> [<argument> <argument>...] [flags]
⚠️ Deprecation notice: using name argument in update contract command will be deprecated soon.
_10flow accounts update-contract <name> <filename> [<argument> <argument>...] [flags]
Example Usage
_18> flow accounts update-contract ./FungibleToken.cdc_18_18Contract 'FungibleToken' updated on account '0xf8d6e0586b0a20c7'_18_18Address 0xf8d6e0586b0a20c7_18Balance 99999999999.70000000_18Keys 1_18_18Key 0 Public Key 640a5a359bf3536d15192f18d872d57c98a96cb871b92b70cecb0739c2d5c37b4be12548d3526933c2cda9b0b9c69412f45ffb6b85b6840d8569d969fe84e5b7_18 Weight 1000_18 Signature Algorithm ECDSA_P256_18 Hash Algorithm SHA3_256_18 Revoked false_18 Sequence Number 6_18 Index 0_18_18Contracts Deployed: 1_18Contract: 'FungibleToken'
Testnet Example
_18> flow accounts update-contract ./FungibleToken.cdc --signer alice --network testnet_18_18Contract 'FungibleToken' updated on account '0xf8d6e0586b0a20c7'_18_18Address 0xf8d6e0586b0a20c7_18Balance 99999999999.70000000_18Keys 1_18_18Key 0 Public Key 640a5a359bf3536d15192f18d872d57c98a96cb871b92b70cecb0739c2d5c37b4be12548d3526933c2cda9b0b9c69412f45ffb6b85b6840d8569d969fe84e5b7_18 Weight 1000_18 Signature Algorithm ECDSA_P256_18 Hash Algorithm SHA3_256_18 Revoked false_18 Sequence Number 6_18 Index 0_18_18Contracts Deployed: 1_18Contract: 'FungibleToken'
Make sure alice account is defined in flow.json
Arguments
Name
- Name:
name
- Valid inputs: Any string value
Name of the contract as it is defined in the contract source code.
⚠️ Deprecation notice: use filename argument only, no need to use name argument.
Filename
- Name:
filename
- Valid inputs: Any filename and path valid on the system.
Filename of the file containing contract source code.
Arguments
- Name:
argument
- Valid inputs: valid cadence values matching argument type in transaction code.
Input arguments values matching corresponding types in the source code and passed in the same order.
Example:
_10> flow accounts update-contract ./contract.cdc Hello 2
Transaction code:
_10access(all) contract HelloWorld {_10 init(a:String, b:Int) {_10 }_10}
Flags
Signer
- Flag:
--signer
- Valid inputs: the name of an account defined in the configuration (
flow.json
)
Specify the name of the account that will be used to sign the transaction.
Show Diff
- Flag:
--show-diff
- Valid inputs:
true
,false
Shows a diff to approve before updating between deployed contract and new contract updates.
Arguments JSON
- Flag:
--args-json
- Valid inputs: arguments in JSON-Cadence form.
- Example:
flow accounts update-contract ./tx.cdc '[{"type": "String", "value": "Hello"}]'
Arguments passed to the Cadence transaction in Cadence JSON format.
Cadence JSON format contains type
and value
keys and is
documented here.