forked from ethereum/EIPs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
58 additions
and
82 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export async function minimalAttestationSample() { | ||
// #################################### ACCOUNTS | ||
// Alice shall get the NFT, oracle signs the attestation off-chain | ||
// Oracle needs to be a trusted Oracle of the smart-contract that shall accept the generated attestation | ||
const [alice, oracle] = await ethers.getSigners(); | ||
|
||
// #################################### CREATE AN ATTESTATION | ||
const to = alice.address; | ||
const anchor = '0x4cc52563699fb1e3333b8aab3ecf016f8fd084e6fc48edf8603d83d4c5b97536' | ||
|
||
const attestationTime = Math.floor(Date.now() / 1000.0); // Now in seconds UTC | ||
const validStartTime = 0; | ||
const validEndTime = attestationTime + 15 * 60; // 15 minutes valid from attestation | ||
|
||
const messageHash = ethers.utils.solidityKeccak256( | ||
["address", "bytes32", "uint256", 'uint256', "uint256"], | ||
[to, anchor, attestationTime, validStartTime, validEndTime] | ||
); | ||
const sig = await signer.signMessage(ethers.utils.arrayify(messageHash)); | ||
|
||
return ethers.utils.defaultAbiCoder.encode( | ||
['address', 'bytes32', 'uint256', 'uint256', 'uint256', 'bytes'], | ||
[to, anchor, attestationTime, validStartTime, validEndTime, sig] | ||
); | ||
} |
This file contains 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 file contains 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