class SStoreOperation extends AbstractOperation {

  @Override
  public OperationResult execute(final MessageFrame frame, final EVM evm) {

    final UInt256 key = UInt256.fromBytes(frame.popStackItem());
    final UInt256 value = UInt256.fromBytes(frame.popStackItem());

    final MutableAccount account =
        frame.getWorldState().getAccount(frame.getRecipientAddress()).getMutable();
    if (account == null) {
      return ILLEGAL_STATE_CHANGE;
    }

    final Address address = account.getAddress();
    final boolean slotIsWarm = frame.warmUpStorage(address, key.toBytes());
    final Gas cost =
        gasCalculator()
            .calculateStorageCost(account, key, value)
            .plus(slotIsWarm ? Gas.ZERO : gasCalculator().getColdSloadCost());

    final Optional<Gas> optionalCost = Optional.of(cost);
    final Gas remainingGas = frame.getRemainingGas();
    if (frame.isStatic()) {
      return new OperationResult(
          optionalCost, Optional.of(ExceptionalHaltReason.ILLEGAL_STATE_CHANGE));
    } else if (remainingGas.compareTo(cost) < 0) {
      return new OperationResult(optionalCost, Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
    } else if (remainingGas.compareTo(minumumGasRemaining) <= 0) {
      return new OperationResult(
          Optional.of(minumumGasRemaining), Optional.of(ExceptionalHaltReason.INSUFFICIENT_GAS));
    }

    // Increment the refund counter.
    frame.incrementGasRefund(gasCalculator().calculateStorageRefundAmount(account, key, value));

    account.setStorageValue(key, value);
    frame.storageWasUpdated(key, value.toBytes());
    return new OperationResult(optionalCost, Optional.empty());
  }

  public  SStoreOperation(final GasCalculator gasCalculator, final Gas minumumGasRemaining);

}