Skip to content

ContractManagement ​

Back to Native Contracts

Manages contract deployment, upgrades, and introspection. The embedded runtime implements the subset needed by compiler/runtime tests; production Neo N3 exposes additional management methods.

Methods ​

MethodSignatureReturnSafeEmbedded runtime status
deploydeploy(bytes,bytes)ContractState❌Implemented with an in-memory registry.
deploydeploy(bytes,bytes,bytes)ContractState❌Implemented; initialization data is accepted by the call.
updateupdate(bytes,bytes)ContractState❌Implemented against the in-memory registry.
updateupdate(bytes,bytes,bytes)ContractState❌Implemented; migration data is accepted by the call.
getContractgetContract(address)ContractState✅Implemented, including a self-contract fallback.
isContractisContract(address)bool✅Implemented for the self contract and registry entries.
hasMethodhasMethod(address,string,uint8)bool✅Implemented using self method offsets or manifest data.
getMinimumDeploymentFeegetMinimumDeploymentFee()uint256✅Implemented as Neo N3's canonical default fee value.

Production methods such as destroy, getContractById, setMinimumDeploymentFee, and listContracts are not implemented by the embedded runtime handler today.

Code Example ​

solidity
import "devpack/contracts/NativeCalls.sol";

contract Upgradeable {
    address private _owner;

    constructor() {
        _owner = msg.sender;
    }

    /// @dev Upgrade this contract in-place
    function upgrade(bytes memory newNef, bytes memory newManifest) public {
        require(Runtime.checkWitness(_owner), "not owner");
        NativeCalls.updateContract(newNef, newManifest);
        // After update, the new code executes immediately
    }

    /// @dev Check if another contract exists
    function contractExists(address target) public view returns (bool) {
        return NativeCalls.hasMethod(target, "name", 0);
    }
}

INFO

The devpack still exposes NativeCalls.destroyContract() and the compiler maps selfdestruct(addr) to production Neo N3 ContractManagement.destroy() with a warning. The embedded runtime used by compiler tests does not model the destructive state deletion; it focuses on deploy, update, and introspection behavior.


MIT Licensed