-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnft_collection.ral
52 lines (46 loc) · 1.3 KB
/
nft_collection.ral
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// The concept of a collection, which could contain different NFTs
// e.g. Bored Ape Yacht Club collection
Contract NFTCollection(
nftTemplateId: ByteVec,
@unused collectionName: ByteVec,
@unused collectionDescription: ByteVec,
@unused collectionUri: ByteVec
) {
event NFTMinted(
minter: Address,
collectionAddress: Address,
name: ByteVec,
description: ByteVec,
uri: ByteVec,
tokenId: ByteVec,
nftContractAddress: Address
)
@using(preapprovedAssets = true, assetsInContract = true)
pub fn mint(
nftName: ByteVec,
nftDescription: ByteVec,
nftUri: ByteVec
) -> (ByteVec) {
let minter = callerAddress!()
let collectionAddress = selfAddress!()
let initialState = encodeToByteVec!(
minter,
true,
nftName,
nftDescription,
nftUri,
collectionAddress
)
let contractId = copyCreateSubContractWithToken!{minter -> 1 alph}(nftUri, nftTemplateId, initialState, 1, minter)
emit NFTMinted(
minter,
collectionAddress,
nftName,
nftDescription,
nftUri,
contractId,
contractIdToAddress!(contractId)
)
return contractId
}
}