Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var contractAddress = "yourContractAddress";
- var abi = JSON.parse('yourContractABI');
- var yourContract;
- window.addEventListener('load', function() {
- // Checking if Web3 has been injected by the browser (Mist/MetaMask)
- if (typeof web3 !== 'undefined') {
- window.web3 = new Web3(web3.currentProvider);
- yourContract = web3.eth.contract(abi).at(contractAddress);
- } else {
- console.log('No web3? You should consider trying MetaMask!')
- }
- })
- //call this function when you want to pass argument to your contract function
- function callYourFunction(){
- var inputData = document.getElementById("IDInputField").value;
- //if your function is a constant function
- yourContract.yourFunction(inputData, function(error, result){
- if(!error){
- console.log(result);
- }
- });
- }
- </script>
- contract Test{
- function yourFunction(uint256 _value) constant returns (uint256) {
- return _value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement