Solidity Call Function

Solidity Programming Language
2 min readNov 2, 2022

--

Code: https://solidity-by-example.org/call/

Note: I changed this code and I found a small error (I wrote to Smart Contract Engineer)

RECEIVER

CALLER

What is the Problem ?

Contract Caller does not know the source code for the Contract Receiver.

But….

It knows the address of contract Receiver(_addr) and the function to call(YouCanCallMe).

Action…

Deploy the receiver contract.

Deploy the caller contract.

Copy the receiver contract address (_addr)

Open the Caller contract and paste Receiver contract address(_addr) to the testCall function add 5 ether to the value(msg.value).

Click the TestCall.

We can control it.

Bingo ! Receiver contract takes the 5 ETH.

Now, we try to sent 5 ether to the function does not exict in Receiver contract. There is no function “TouCanCallMe” in receiver contract.

Open the Caller contract and paste Receiver contract address(_addr) to the testCallDoesNotExist function and add 3 ether to the value(msg.value).

Click the testCallDoesNotExist.

Yes. There is no TouCanCallMe” function in receiver contract but we have fallback function and receiver contract takes this ether using the fallback function.Receiver contract’s balance is now 8 ETH.

Doç.Dr. Engin YILMAZ

--

--

Solidity Programming Language
Solidity Programming Language

Written by Solidity Programming Language

Solidity basics for beginners: Learn the fundamentals of smart contract development and build your first DApp! #Solidity #Foundry #Ethereum #Opcodes #DApps

No responses yet