Fix incorrect JS slice in ERC-20 example #2651
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixed issues in the ERC-20 transfer example regarding the generation of the function selector:
The original example used the incorrect syntax
[0..4]in JavaScript. It has been corrected to use.slice(0, 10)to correctly extract the first 4 bytes of the hash plus the0xprefix.The example incorrectly used the
Transferevent as if it were a function for sending tokens.Transferis an ERC-20 event, not a function, and cannot be called directly. The example has been updated to generate the selector for the correcttransfer(to,value)function.Note
Updates the ERC-20 "Send transactions" example to correctly derive the
transfer(address,uint256)function selector.web3.sha3("Transfer(address, address, uint256)")[0..4]withweb3.utils.sha3("transfer(address,uint256)").slice(0, 10)for proper 4-byte selector extractionWritten by Cursor Bugbot for commit f2e14a8. This will update automatically on new commits. Configure here.