EatTheBlocks Forum

Sending Ether in Truffle console environment


I have two contracts:

pragma solidity ^0.5.8;

contract SC1 {
    event Log(uint gas);

    // Fallback function must be declared as external.
    function() external payable {
        // send / transfer (forwards 2300 gas to this fallback function)
        // call (forwards all of the gas)
        emit Log(gasleft());

    // Helper function to check the balance of this contract
    function getBalance() public view returns (uint) {
        return address(this).balance;


        pragma solidity ^0.5.8;
        contract SC2 {
            function transferToFallback(address payable _to) public payable {

            function callFallback(address payable _to) public payable {
                //(bool success,) =; 
                //(bool success,) ={value: msg.value}(payload);
                //require(success, "Ether transfer failed.");
                (bool sent, ) ="");
                require(sent, "Failed to send Ether");
           function() external payable{

I am sending Ether from SendtFallback smart contract (SC)to Fallback SC but Fallback balance is zero and SendToFallback balance does not change. I think the problem is with the signature of transferToFallback function of SendToFallback SC. It does not accept any argument for sending Ether. Please guide me how to send Ether from SendToFallback Smart Contract to Fallback.

My Work:
I have used truffle console for sending Ether. I am using the following command:
)> senderSTB.transferTo(receiverFB.address, {from:accounts[0]})

The migration file i.e. 2_deploy_contracts.js is:

const FB = artifacts.require(“Fallback”);
const STFB = artifacts.require(“SendToFallback”);

module.exports = function(deployer) {

Complete steps are provided at: Problem with transferring Ether in Truffle console