Constructor Arguments
Solidity constructors map to Neo's _deploy(data, update) entry point. The compiler automatically generates this entry point for contracts with constructors.
How It Works
- The compiler emits a
_deploy(data, update)method in the NEF. - On initial deployment (
update = false), the deploy stub deserializesdataand passes the values to your Solidity constructor logic. - On contract update (
update = true), the constructor is skipped.
Passing Constructor Arguments
Neo-Express / CLI tooling: Pass a JSON array string as the -d flag:
# Constructor: constructor(uint256 initialValue)
$NEOXP contract deploy -i chain.neo-express -d '[7]' build/Counter.nef node1
# Constructor: constructor(uint256 amount, string name)
$NEOXP contract deploy -i chain.neo-express -d '[1000, "MyToken"]' build/Token.nef node1Neo SDKs (C#, Python, JS): Pass a StackItem Array directly through the SDK's deploy API.
Contract-to-contract deployment: Use abi.encode(...) to produce StdLib.serialize bytes, which the deploy stub can also accept.
Manifest Requirements
Contracts with parameterized constructors require these permissions in the manifest:
StdLib.jsonDeserializeStdLib.deserialize
The compiler adds these automatically. You can verify:
jq '.permissions' build/Counter.manifest.jsonWARNING
If you use --deny-wildcard-methods and the compiler cannot narrow the StdLib permissions, compilation will fail. In that case, provide an explicit --manifest-permissions file that includes the required StdLib methods.
