CRYPTO NEWS

linking form submission to smart contract

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);     count++; }   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">    <body>             <h1 >send ___ ether to ___ </h1>           <br/>            <!-- 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"           </form>      <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>     <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) {         contract.sendViaCall($('input').val());       })      </script>   </body> </html> 

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

What is the best algorithm for compressing a hash?

What is the best way to transform a hash with a longer length into one with a smaller length, preventing as many collisions as possible? (Hashing the hash) For example: Some versions of Git use SHA-1 for hashing commits. Of course, 15ce7ff90976b3e43738be403f5c985377646bb3 is rather large to display on a screen. Because of that, Github usually::Listen

What is the best way to transform a hash with a longer length into one with a smaller length, preventing as many collisions as possible? (Hashing the hash)

For example: Some versions of Git use SHA-1 for hashing commits. Of course, 15ce7ff90976b3e43738be403f5c985377646bb3 is rather large to display on a screen. Because of that, Github usually only shows the most significant 4 bytes (15ce7ff9) to refer to a specific commit.

But is this the best strategy or is there a better way? If SHA-256 was used instead of SHA-1, would the resulting “minified” hash be as secure and as colision-avoiding as possible within 4 bytes, regardless of the “minification” algorithm used?

linking form submission to smart contract

Shopping cart
There are no products in the cart!
Continue shopping
0