Execute a Smart Contract Method
Learn how to execute smart contract methods from a web application.
We'll cover the following
In the previous lesson, we saw how to read data from a smart contract and use this data to populate our application’s UI. In this lesson, we'll continue improving our frontend and implement a feature that'll allow users to send bids to an Auction
smart contract.
Executing a smart contract method
The last feature we'll implement will allow users to send bids to the Auction
smart contract. We already have the BidInput
component that renders components to input a bid amount and place a bid, so all we need to do is update this component to send an Ethereum transaction that'll execute the placeBid
method.
To implement this, we need to add two new properties to the BidInput
component that we'll use later to send a transaction:
contractAddress
: This is the address of the contract that the user has provided. We'll use it to specify where to send the transaction.currentAccount
: This is the address of the current user’s account in MetaMask.
Get hands-on with 1400+ tech skills courses.