For Example:
I have a website and on the website there is an input box that allows the user to input a number.
Say he inputs 10, can that number then be passed to an empty variable in the smart contract?
For Example:
I have a website and on the website there is an input box that allows the user to input a number.
Say he inputs 10, can that number then be passed to an empty variable in the smart contract?
As @Badr Bellaj says, you can use web3.js framework.
Here is a simple example using web3.js and Metamask.
<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>
Here is a simple test contract
contract Test{
function yourFunction(uint256 _value) constant returns (uint256) {
return _value;
}
}
You can read more on:
Contract Methods - https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods
sendTransaction - https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsendtransaction