Skip to content

Extract Hash Calculation Logic into a Separate Function #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions scripts/simpleMintAndRegisterSpg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ const main = async function () {
description: 'This NFT represents ownership of an IP Asset',
image: 'https://i.imgur.com/gb59b2S.png',
}

const calculateHash = (data: any): string {
return createHash('sha256').update(JSON.stringify(data)).digest('hex')
}
// 4. Upload your IP and NFT Metadata to IPFS
const ipIpfsHash = await uploadJSONToIPFS(ipMetadata)
const ipHash = createHash('sha256').update(JSON.stringify(ipMetadata)).digest('hex')
const ipHash = calculateHash(ipMetadata)
const nftIpfsHash = await uploadJSONToIPFS(nftMetadata)
const nftHash = createHash('sha256').update(JSON.stringify(nftMetadata)).digest('hex')
const nftHash = calculateHash(nftMetadata)

// 5. Register the NFT as an IP Asset
//
Expand Down