Let's assume I do a transaction to a contract function with my external account, then I have to pay gas for this transaction.
If the function within the contracts makes now a transaction on his own to write something to an other contracts, who is paying then for this?
I was testing this in my truffle develop
environment and it looks like my account just paid for the transaction to the first contract, not for the second transaction.
I also didn't send any Ether to the first contracts before. But the second transaction worked as well.
- Are transaction from contracts free?
- Or is this just a special behaviour in my test environment to make thing easier?
edit:
The contract makes a simple transaction, something like this:
contract First {
Second secondContract;
uint test;
function setSomething(uint _testValue) external {
secondContract.set(_testValue); //also set a uint within contract 2
test = _testValue;
}
}
If I add the following line in my test, the result is 0 Ether because I never send Ether to this contract.
console.log(`Contract balance: ${web3.fromWei(web3.eth.getBalance(firstContact.address))}`);
The test still works and if i read the value from the second contract I also get the right value back.