Let's say I am creating a contract from another contract by calling a function in a parent contract, is the gas required to create new contract included in running the function that creates new contract?
pragma solidity ^0.4.15;
contract Test {
bool public active = true;
address public owner;
address public contract_address;
uint public amountReceived;
address[] public activeContracts;
uint256 public gasLeft;
function () payable {
amountReceived = msg.value;
gasLeft = msg.gas;
}
function Test() {
owner = msg.sender;
contract_address = this;
gasLeft = msg.gas;
}
function updateStatus() {
active = false;
}
function kill() {
selfdestruct(owner);
gasLeft = msg.gas;
}
function createSubContract() {
address newContractAddress = new SubTest();
activeContracts.push(newContractAddress);
gasLeft = msg.gas;
}
}
contract SubTest {
address public owner;
address public contract_address;
uint256 public amountReceived;
uint256 public gasLeft;
function () payable {
amountReceived = msg.value;
gasLeft = msg.gas;
}
function SubTest() {
owner = msg.sender;
contract_address = this;
gasLeft = msg.gas;
}
function kill() {
selfdestruct(owner);
gasLeft = msg.gas;
}
}
Here is a sample contract I am testing. Inorder to create a subcontract I call the function createSubContract, does gas required for calling this function include the gas required to create the contract?