A query that returns the bytecode for a smart contract instance**.** Anyone can request the byte code of a smart contract instance on the network. Queries do not change the state of the smart contract or require network consensus. The information is returned from a single node processing the query.
Query Signing Requirements
The client operator account's private key (fee payer) is required to sign this query
Query Fees
Please see the transaction and query fees table for the base transaction fee
//Create the queryContractByteCodeQuery query =newContractByteCodeQuery().setContractId(contractId);//Sign with the client operator private key and submit to a Hedera networkByteString bytecode =query.execute(client);
//Create the queryconstquery=newContractByteCodeQuery().setContractId(contractId);//Sign with the client operator private key and submit to a Hedera networkconstbytecode=awaitquery.execute(client);
//Create the queryquery :=hedera.NewContractByteCodeQuery().SetContractID(contractId)//Sign with the client operator private key to pay for the query and submit the query to a Hedera networkbytecode, err :=query.Execute(client)if err != nil {panic(err)}
Get query values
Method
Type
Description
Requirements
getContractId(<contractId>)
ContractId
Get the contract ID on the transaction
Required
//Create the queryContractByteCodeQuery query =newContractByteCodeQuery().setContractId(newContractId);//Get the contract IDquery.getContractId()//v2.0.0
//Create the queryconst query =newContractByteCodeQuery().setContractId(newContractId);//Get the contract IDquery.getContractId()//v2.0.0
//Create the queryquery :=hedera.NewContractByteCodeQuery().SetContractID(contractId)query.GetContractID()//v2.0.0