Solidity REPL
Contracts & calls

Base constructor arguments

Pass constructor arguments from a derived contract to its base.

Solidity 0.8.36REPL mode

Why use this example

Use this pattern to test contract composition, external calls, events, and return values inside one reproducible run. The entry isolates base constructor arguments so its input, result, and state changes stay easy to compare.

Solidity to run

contract BaseValue {
  uint256 public value;
  constructor(uint256 initialValue) { value = initialValue; }
}
contract DerivedValue is BaseValue(40) {
  function answer() external view returns (uint256) { return value + 2; }
}

DerivedValue derived = new DerivedValue()
derived.value()
derived.answer()

Official Solidity reference

Compare this focused investigation with the complete language definition in the Solidity documentation.

Arguments for base constructors

What to expect

The derived contract passes 40 into its base constructor, and its own function adds two to return 42.

Continue the investigation

Change a value, add another expression, or open Inspect after the run. Accepted entries remain available to the next entry, and the clean replay keeps the complete result reproducible.

Read about calls and logs Reproducible investigation