Making transactions on blockchain
In this section, we will explore how to make transactions with the ethers.js and web3-react libraries. Meanwhile, we will complete the functions of transferring tokens on the TOKEN OPERATIONS page.
In Figure 3.1, we created four text fields that require a user to input the recipient’s address and transferring amount for the two transfer cases:
- Normal Transfer: This transfers the specified amount of tokens from one address to another address without any loss, and calls ERC20’s standard
transfer
function. - Transfer with Burn: This transfers the specified amount of tokens from the sender’s address, burns 10% of them, and sends the remaining 90% of the tokens to the recipient’s address. We will call the custom
transferWithAutoBurn
function we defined insrc/backend/contracts/SimpleDeFiToken.sol
.
Let’s define the following four state variables for the four TextField
values in src/frontend/features...