I have a smart contract that sends x ether to an address. I have an html page that has a form for the address, and the amount to be sent. Theoretically it should interface with the smart contract. Nothing happens when i submit the form. It doesn't work on remix or ganache. On my form, do i have to specify a form action as i would in html? Would the contract not do that?

The html file is similar to https://github.com/dappuniversity/20_minute_dapp/blob/master/index.html but the forms/variables are changed and all the css and formatting is removed.

my sol

pragma solidity ^0.5.11;

contract ReceiveEther {

uint256 public count;

function () external payable {
    require(count < 2);

function getBalance() public view returns (uint) {
    return address(this).balance;


contract SendEther {
    function sendViaCall (address payable _to) public payable {
        (bool sent, bytes memory data) = _to.call.value(msg.value)("");
        require (sent, "failed to send ether");

My html

<!DOCTYPE html>
<html lang="en">

            <h1 >send ___ ether to ___ </h1>

          <!-- in html/php i have to say what is executed on form submit (usually a php action).
          Since the smart contract is doing it, do i need to specify anything here or can i do 
it down below? -->

          <form role="form">
            <label for="Receiver">Receiver:</label><br>
            <input type="text" id="receiver" name="receiver" ><br>
            <label for="lname">amount in eth:</label><br>
            <input type="text" id="amount" name="amount" >
            <input type="submit" value="Submit"

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/web3.min.js"></script>

      // Starting Web3
      if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
      } else {
        web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));

      // stating account
      web3.eth.defaultAccount = web3.eth.accounts[0];

// Stating Contract Abi
      var contractAbi = [WHATEVER THE ABI IS ];

      // Stating Contract Address
      var contractAddress = 'WHATEVER THE ADDRESS IS';

      // matching abi to contract
      var contract = web3.eth.contract(contractAbi).at(contractAddress);

      // action on submit
      $('form').on('submit', function(sendViaCall) {


I feel the issue is related to the submission, but what do I know. Thank you for any guidance

1 Answer 1


Note, the DappUniversity tutorials require Ganache or ganache-cli local blockchain running.

Web3js is trying to connect to the local blockchain on this line:

 web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));

Go ahead and download Ganache here. You will also need to specify contractAddress & contractAbi. Ganache will give you several dummy accounts funded with fake ETH you can use for testing.

  • I understand, and I have been doing this with Ganache. However, it is still not working. I have been entering the appropriate ABI and address when running the program, but did not post it in the example.
    – rubecuber
    May 8, 2020 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.