Friday, July 7, 2023

151: Calling Blockchain Functions From React

 Today I started implemented the actual web3 functionality in our app. Again, this is accomplished via the ethereum object injected into our window by Metamask. All of this logic is contained within the app context, so it can be selectively called in other components as needed. In order to create an instance of our contract, we give the ethers library our contract address, contract ABI, and signer. The signer is pulled from the ethereum window object as already mentioned, whereas the contract address and ABI must be stored somewhere in our app files. I have mine in a folder called constants, structured with export statements to provide the string of the address and JSON of the ABI wherever needed. 

No comments:

Post a Comment

190: Sablier

 The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...