Metamask Problem: ERC721 Marker Confirmation Checking Hardhat script vs React
Wen Here are Metamk API and Solidity Contractors, you are certain edges that can be more. The Comon edition has one test with marker approval for ERC721 tokens, which is a loop in the Hardhat script application.
In this article we will study
Hardhat Script Issued
You can “transfer” the ERC721 marker function in the Hardhat script. By checking the marker approvals of the same contractors on the loop, you can encounter questions with
`JavaScript
Constatearr = ['0x123456790abcdef'];
Modifier Isapproed (Address [] Memory CONTRAACTARR) {
Request (Contractarr.lenght> 0, "Length Zero");
for (let i = 0; i
Const tokenaddress = CONTRAACTARR [I];
Agreement [Tokenaddress] .Appove (address.from, address.value);
}
}
The question of using the “transfer” function returns “true” immediately after the deal. However, in the loop, you should check that the approval is properly updated.
REACT QUESTION
ReCT application test marker approvals for ERC721 The marker may be more complicated
`JavaScript
Import {contract} from './ Contractors/ ERC721.SOL';
Import Web3 from Web3;
Constatearr = ['0x123456790abcdef'];
The function is appropriate (address) {
Const Web3 = New Web3 (window.eterum);
retract.erc721.Isaproved (contraction.address, eddress.value);
}
In this example of response, “ISAPROVED” features thes
Solution
*
To solve their both hardhat scripts and react in applications, you can have a different approach:
API to update your contractor’s condition.
`JavaScript
Constatearr = ['0x123456790abcdef'];
Modifier Isapproed (Address [] Memory CONTRAACTARR) {
Request (Contractarr.lenght> 0, "Length Zero");
for (let i = 0; i
Const tokenaddress = CONTRAACTARR [I];
EVENTRANSFERCOMPLETE (Tokenaddress) .Mit ('evaluation', {status: True});
// Update the state of contraction
Agreement [Tokenaddress] .Appove (address.from, address.value);
}
}
- Use the call to the event “Transfer”
: PPLE status is updated.
`JavaScript
Constatearr = ['0x123456790abcdef'];
EVENTRANSFERCOMPLETE (Tokenaddress) .on ('evaluation', (status) => {
IF (Status.Stus == True) {
// Update the state of contraction
Agreement [Tokenaddress] .Appove (address.from, address.value);
}
});
With approaches, you can make sure that your contractions are checked for the correct evaluation of the marker in both solid and reactions.
Conclusion *
When there are Metamask API and Solidity contractions, it is important to be aware of Isuli Issuicly test on markers. Understanding the mechanical mechanisms of the “transfer” of the “transfer” function and you can in both ICates using the EMTERS or Calling Functional Event.