Skip to content

Instantly share code, notes, and snippets.

@4gus71n
Last active Jun 18, 2018
Embed
What would you like to do?
Testing Dapps
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>
<script>
$( document ).ready(function() {
var Web3 = require('web3');
var address = "0xcbbfbafedb0eb83016d2a96a4e80d30b20fa3e30"
//var host = "http://faucet.ropsten.be:3001/"
//var host = "https://ropsten.infura.io/mx6qGhHuS8BIEGhecvbX/"
//var host = "https://infuranet.infura.io/mx6qGhHuS8BIEGhecvbX/"
var host = "https://kovan.infura.io/mx6qGhHuS8BIEGhecvbX/"
//var host = "https://rinkeby.infura.io/mx6qGhHuS8BIEGhecvbX/"
//var host = "https://ipfs.infura.io/"
//var host = "http://localhost:8545"
//var host = "https://ropsten.infura.io"
web3 = new Web3(new Web3.providers.HttpProvider(host));
//web3.eth.defaultAccount = web3.eth.coinbase
//web3.eth.defaultAccount = web3.eth.accounts[0];
web3.eth.defaultAccount = address
var version = web3.version.api;
var contractABI = JSON.parse('[{"constant": false,"inputs": [{"name": "hash","type": "bytes32"}],"name": "apply","outputs": [],"payable": false,"stateMutability": "nonpayable","type": "function"},{"constant": true,"inputs": [{"name": "email","type": "string"}],"name": "getApplicationID","outputs": [{"name": "","type": "uint256"}],"payable": false,"stateMutability": "view","type": "function"}]');
var MyContract = web3.eth.contract(contractABI);
var myContractInstance = MyContract.at(address);
var result = myContractInstance.apply("agustin.tomas.larghi@gmail.com")
console.log("result1 : " + result);
var result = myContractInstance.getApplicationID(result);
console.log("result2 : " + result);
});
</script>
</head>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment