Last active
November 17, 2022 23:44
-
-
Save Austinhs/d130766601a6ad72e5a1146aed74df26 to your computer and use it in GitHub Desktop.
example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| modifier canChangeUri(uint256[] memory tokens, string calldata ipfs_uri, bytes calldata signature) { | |
| require(_signer == keccak256(abi.encodePacked( | |
| msg.sender, | |
| tokens, | |
| ipfs_uri | |
| )).toEthSignedMessageHash().recover(signature), "Not approved URI"); | |
| _; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| this.signUriChange = async(wallet, tokens, uri) => { | |
| const message = [wallet, tokens, uri]; | |
| const hash = ethers.utils.solidityKeccak256(["address", "uint[]", "string"], message); | |
| const binary = ethers.utils.arrayify(hash); | |
| const signature = await this.serverSigner.signMessage(binary); | |
| return { | |
| tokens, | |
| uri, | |
| signature | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment