Skip to content

Instantly share code, notes, and snippets.

@Austinhs
Last active November 17, 2022 23:44
Show Gist options
  • Select an option

  • Save Austinhs/d130766601a6ad72e5a1146aed74df26 to your computer and use it in GitHub Desktop.

Select an option

Save Austinhs/d130766601a6ad72e5a1146aed74df26 to your computer and use it in GitHub Desktop.
example
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.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