SHARE
TWEET

Untitled

finalshare May 18th, 2018 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     function a2hex(str) {
  3.         var arr = [];
  4.         for (var i = 0, l = str.length; i < l; i ++) {
  5.             var hex = Number(str.charCodeAt(i)).toString(16).padStart(2,'0');
  6.             arr.push(hex);
  7.         }
  8.         return arr.join('');
  9.     }
  10.  
  11.     function toAddr(str){
  12.         return "0x" + a2hex(str);
  13.     }
  14.  
  15.     var Web3 = require('web3');
  16.     var web3 = new Web3();
  17.     web3.setProvider(new Web3.providers.HttpProvider('https://ropsten.infura.io/')); // https://ropsten.etherscan.io/
  18.     var criticoContractABI =[{"constant": true,"inputs": [{"name": "flag","type": "address"}],"name": "doSomething","outputs": [{"name": "","type": "bool"}],"payable": false,"stateMutability": "pure","type": "function"}];
  19.  
  20.     var critico = web3.eth.contract(criticoContractABI);
  21.     var critInstance = critico.at('0x44f0d8e171c79da5318f4e72a848be7f0ea1cad3'); // contract address
  22.     $('.submit-button').click(function() {
  23.         $(".message").text("Checking...");
  24.         var ret = critInstance.doSomething.call(toAddr($(".text-input").val()));
  25.         if (ret)
  26.             $(".message").text("Congratz, submit it with flag format!");
  27.         else
  28.             $(".message").text("Nah!");
  29.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top