From 15211e497e4e0df6bb4494c777370a0a082e285e Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 28 Apr 2025 16:36:16 +0300 Subject: [PATCH 1/3] add command to unverify smart contract --- CLI.md | 41 ++++++++++++++++++++- multiversx_sdk_cli/cli_contracts.py | 55 +++++++++++++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/CLI.md b/CLI.md index 9c8e9845..79de3032 100644 --- a/CLI.md +++ b/CLI.md @@ -58,7 +58,7 @@ usage: mxpy contract COMMAND [-h] ... Deploy, upgrade and interact with Smart Contracts COMMANDS: - {deploy,call,upgrade,query,verify,reproducible-build,build} + {deploy,call,upgrade,query,verify,unverify,reproducible-build,build} OPTIONS: -h, --help show this help message and exit @@ -71,6 +71,7 @@ call Interact with a Smart Contract (execute function) upgrade Upgrade a previously-deployed Smart Contract. query Query a Smart Contract (call a pure function) verify Verify the authenticity of the code of a deployed Smart Contract +unverify Unverify a previously verified Smart Contract reproducible-build Build a Smart Contract and get the same output as a previously built Smart Contract build Build a Smart Contract project. This command is DISABLED. @@ -129,6 +130,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --proxy PROXY 🔗 the URL of the proxy --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. @@ -222,6 +224,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --proxy PROXY 🔗 the URL of the proxy --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. @@ -325,6 +328,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --proxy PROXY 🔗 the URL of the proxy --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. @@ -416,6 +420,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation ``` ### Contract.ReproducibleBuild @@ -504,6 +509,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -610,6 +616,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --infile INFILE input file (a previously saved transaction) --outfile OUTFILE where to save the output (the signed transaction) (default: stdout) --send ✓ whether to broadcast the transaction (default: False) @@ -724,6 +731,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -780,6 +788,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -834,6 +843,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -888,6 +898,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -942,6 +953,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -996,6 +1008,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1049,6 +1062,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1103,6 +1117,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1157,6 +1172,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1211,6 +1227,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1265,6 +1282,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1318,6 +1336,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1411,6 +1430,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1483,6 +1503,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1539,6 +1560,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1595,6 +1617,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1651,6 +1674,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1707,6 +1731,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1763,6 +1788,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1817,6 +1843,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1871,6 +1898,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1925,6 +1953,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -1979,6 +2008,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2033,6 +2063,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2088,6 +2119,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2143,6 +2175,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2199,6 +2232,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2255,6 +2289,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2312,6 +2347,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2369,6 +2405,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --nonce NONCE # the nonce for the transaction. If not provided, is fetched from the network. --recall-nonce ⭮ whether to recall the nonce when creating the transaction (default: @@ -2510,6 +2547,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation ``` ### Wallet.VerifyMessage @@ -3030,6 +3068,7 @@ options: --sender-wallet-index SENDER_WALLET_INDEX 🔑 the address index; can be used for PEM files, keyfiles of type mnemonic or Ledger devices (default: 0) --sender-username SENDER_USERNAME 🖄 the username of the sender + --hrp HRP The hrp used to convert the address to its bech32 representation --chain {D,T} the chain identifier --api API custom api url for the native auth client --wallet-url WALLET_URL custom wallet url to call the faucet from diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index cb9df27c..e192baa6 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -4,9 +4,11 @@ from pathlib import Path from typing import Any +import requests from multiversx_sdk import ( Address, AddressComputer, + Message, ProxyNetworkProvider, Transaction, TransactionsFactoryConfig, @@ -179,6 +181,27 @@ def setup_parser(args: list[str], subparsers: Any) -> Any: cli_shared.add_wallet_args(args, sub) sub.set_defaults(func=verify) + sub = cli_shared.add_command_subparser( + subparsers, + "contract", + "unverify", + "Unverify a previously verified Smart Contract", + ) + + _add_contract_arg(sub) + sub.add_argument( + "--code-hash", + required=True, + help="the code hash of the contract", + ) + sub.add_argument( + "--verifier-url", + required=True, + help="the url of the service that validates the contract", + ) + cli_shared.add_wallet_args(args, sub) + sub.set_defaults(func=unverify) + sub = cli_shared.add_command_subparser( subparsers, "contract", @@ -524,6 +547,13 @@ def _send_or_simulate(tx: Transaction, contract_address: Address, args: Any): def verify(args: Any) -> None: + response = input( + "Are you sure you want to verify the contract? This will publish the contract's source code, which will be displayed on the MultiversX Explorer (y/n): " + ) + if response.lower() != "y": + logger.info("Contract verification cancelled.") + return + contract = Address.new_from_bech32(args.contract) verifier_url = args.verifier_url @@ -537,6 +567,31 @@ def verify(args: Any) -> None: logger.info("Contract verification request completed!") +def unverify(args: Any) -> None: + account = cli_shared.prepare_account(args) + contract = args.contract + code_hash = args.code_hash + verifier_url = f"{args.verifier_url}/verifier" + + payload = { + "contract": contract, + "codeHash": code_hash, + } + + payload_json = json.dumps(payload, separators=(",", ":")) + message = Message(payload_json.encode()) + signature = account.sign_message(message) + + request_payload = { + "signature": signature.hex(), + "payload": payload_json, + } + + response = requests.delete(verifier_url, json=request_payload) + logger.info(f"Your request to unverify contract {contract} was submitted.") + print(response.json().get("message")) + + def do_reproducible_build(args: Any): project_path = args.project docker_image = args.docker_image diff --git a/pyproject.toml b/pyproject.toml index 7b925fc9..a7b38afc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "multiversx-sdk-cli" -version = "10.1.1" +version = "10.2.0" authors = [ { name="MultiversX" }, ] From 65a76dd0b872fa7b924639adaee70903b1d2da2f Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 29 Apr 2025 14:09:35 +0300 Subject: [PATCH 2/3] fix for unverify contract --- multiversx_sdk_cli/cli_contracts.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index e192baa6..f79dfe48 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -1,3 +1,4 @@ +import hashlib import json import logging import os @@ -569,25 +570,28 @@ def verify(args: Any) -> None: def unverify(args: Any) -> None: account = cli_shared.prepare_account(args) - contract = args.contract - code_hash = args.code_hash - verifier_url = f"{args.verifier_url}/verifier" + contract: str = args.contract + code_hash: str = args.code_hash + verifier_url: str = f"{args.verifier_url}/verifier" payload = { "contract": contract, "codeHash": code_hash, } - payload_json = json.dumps(payload, separators=(",", ":")) - message = Message(payload_json.encode()) - signature = account.sign_message(message) + serialized_payload = json.dumps(payload, separators=(",", ":")).encode("utf-8") + hash = hashlib.sha256(serialized_payload).hexdigest() + message_to_sign = (contract + hash).encode("utf-8") + + signature = account.sign_message(Message(message_to_sign)) request_payload = { "signature": signature.hex(), - "payload": payload_json, + "payload": payload, } - response = requests.delete(verifier_url, json=request_payload) + headers = {"Content-type": "application/json"} + response = requests.delete(verifier_url, json=request_payload, headers=headers) logger.info(f"Your request to unverify contract {contract} was submitted.") print(response.json().get("message")) From 352900ac4565fa933448a2e6c07025705b44fe36 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Tue, 29 Apr 2025 15:00:35 +0300 Subject: [PATCH 3/3] add args to skip confirmation prompt --- multiversx_sdk_cli/cli_contracts.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/multiversx_sdk_cli/cli_contracts.py b/multiversx_sdk_cli/cli_contracts.py index f79dfe48..7ad92e1f 100644 --- a/multiversx_sdk_cli/cli_contracts.py +++ b/multiversx_sdk_cli/cli_contracts.py @@ -180,6 +180,14 @@ def setup_parser(args: list[str], subparsers: Any) -> Any: help="in case of a multicontract, specify the contract variant you want to verify", ) cli_shared.add_wallet_args(args, sub) + sub.add_argument( + "--skip-confirmation", + "-y", + dest="skip_confirmation", + action="store_true", + default=False, + help="can be used to skip the confirmation prompt", + ) sub.set_defaults(func=verify) sub = cli_shared.add_command_subparser( @@ -548,12 +556,13 @@ def _send_or_simulate(tx: Transaction, contract_address: Address, args: Any): def verify(args: Any) -> None: - response = input( - "Are you sure you want to verify the contract? This will publish the contract's source code, which will be displayed on the MultiversX Explorer (y/n): " - ) - if response.lower() != "y": - logger.info("Contract verification cancelled.") - return + if not args.skip_confirmation: + response = input( + "Are you sure you want to verify the contract? This will publish the contract's source code, which will be displayed on the MultiversX Explorer (y/n): " + ) + if response.lower() != "y": + logger.info("Contract verification cancelled.") + return contract = Address.new_from_bech32(args.contract) verifier_url = args.verifier_url