I am taking a look at Solidity, because the concept of smart contracts is starting to interest me.
I see how Solidity can be used to code smart contracts. But the language does for example not contain a library to code a user interface.
So that means that Solidity gets it data from an external source?
Let's examine the Open Auction example from the docs.
/// Bid on the auction with the value sent
/// together with this transaction.
/// The value will only be refunded if the
/// auction is not won.
function bid() external payable {
// No arguments are necessary, all
// information is already part of
// the transaction. The keyword payable
// is required for the function to
// be able to receive Ether.
// Revert the call if the bidding
// period is over.
if (block.timestamp > auctionEndTime)
revert AuctionAlreadyEnded();
// If the bid is not higher, send the
// money back (the revert statement
// will revert all changes in this
// function execution including
// it having received the money).
if (msg.value <= highestBid)
revert BidNotHighEnough(highestBid);
if (highestBid != 0) {
// Sending back the money by simply using
// highestBidder.send(highestBid) is a security risk
// because it could execute an untrusted contract.
// It is always safer to let the recipients
// withdraw their money themselves.
pendingReturns[highestBidder] += highestBid;
}
highestBidder = msg.sender;
highestBid = msg.value;
emit HighestBidIncreased(msg.sender, msg.value);
}
This function allows the user to do a bid on the auction. But nowhere asks the user to enter the value he wants to bid using a user-input. I only see msg.value
. A quick Google search tells me that msg
is a global variable which lets me access the request send to the smart contract and msg.value
is the content of that request.
My question is: How does one send a message to the smart contract? If I'd deploy the Open Auction smart contract on Ethereum, could I use HTTP-requests to send a message to the contract?
If I had the following HTML interface:
<form>
<label>Value you want to bid:</label>
<input type="number" name="value_to_bid" value="">
<input type="submit" name="submit_bid" value="bid">
</form>
which is simply a user input asking the user for the value he wants to bid on the auction. How would I send the entered value to a Ethereum smart contract (in theory, not asking for code)?
TL;DR: I don't understand how the theory behind how one would communicate with a smart contract.