forked from thirdweb-dev/go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
erc721_signature_minting.go
667 lines (577 loc) · 21.1 KB
/
erc721_signature_minting.go
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
package thirdweb
import (
"context"
"encoding/hex"
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
signerTypes "github.com/ethereum/go-ethereum/signer/core/apitypes"
"github.com/google/uuid"
"github.com/mry-am/thirdweb-go-sdk/v2/abi"
)
// You can access this interface from the NFT Collection contract under the
// signature interface.
type ERC721SignatureMinting struct {
legacy *abi.TokenERC721
extension *abi.SignatureMintERC721
Helper *contractHelper
storage storage
}
func newERC721SignatureMinting(provider *ethclient.Client, address common.Address, privateKey string, storage storage) (*ERC721SignatureMinting, error) {
legacy, err := abi.NewTokenERC721(address, provider)
if err != nil {
return nil, err
}
extension, err := abi.NewSignatureMintERC721(address, provider)
if err != nil {
return nil, err
}
helper, err := newContractHelper(address, provider, privateKey)
if err != nil {
return nil, err
}
return &ERC721SignatureMinting{
legacy,
extension,
helper,
storage,
}, nil
}
// Mint a token with the data in given payload.
//
// signedPayload: the payload signed by the minters private key being used to mint
//
// returns: the transaction receipt of the mint
//
// Example
//
// // Learn more about how to craft a payload in the Generate() function
// signedPayload, err := contract.Signature.Generate(payload)
// tx, err := contract.Signature.Mint(context.Background(), signedPayload)
// Deprecated: use MintAndAwait
func (signature *ERC721SignatureMinting) Mint(ctx context.Context, signedPayload *SignedPayload721) (*types.Transaction, error) {
return signature.MintAndAwait(ctx, signedPayload)
}
func (signature *ERC721SignatureMinting) MintAndAwait(ctx context.Context, signedPayload *SignedPayload721) (*types.Transaction, error) {
txOpts, err := signature.Helper.GetTxOptions(ctx)
if err != nil {
return nil, err
}
tx, err := signature.MintWithOpts(ctx, signedPayload, txOpts)
if err != nil {
return nil, err
}
return signature.Helper.AwaitTx(ctx, tx.Hash())
}
func (signature *ERC721SignatureMinting) MintWithOpts(ctx context.Context, signedPayload *SignedPayload721, txOpts *bind.TransactOpts) (*types.Transaction, error) {
if signature.isLegacyContract(ctx) {
message, err := mapLegacyPayloadToContractStruct(signedPayload.Payload)
if err != nil {
return nil, err
}
if err := setErc20Allowance(
ctx,
signature.Helper,
message.Price,
message.Currency.String(),
txOpts,
); err != nil {
return nil, err
}
signatureBytes, err := hex.DecodeString(signedPayload.Signature[2:])
if err != nil {
return nil, err
}
return signature.legacy.MintWithSignature(txOpts, *message, signatureBytes)
} else {
message, err := mapPayloadToContractStruct(signedPayload.Payload)
if err != nil {
return nil, err
}
if err := setErc20Allowance(
ctx,
signature.Helper,
message.PricePerToken,
message.Currency.String(),
txOpts,
); err != nil {
return nil, err
}
signatureBytes, err := hex.DecodeString(signedPayload.Signature[2:])
if err != nil {
return nil, err
}
return signature.extension.MintWithSignature(txOpts, *message, signatureBytes)
}
}
// Mint a batch of token with the data in given payload.
//
// signedPayload: the list of payloads signed by the minters private key being used to mint
//
// returns: the transaction receipt of the batch mint
//
// Example
//
// // Learn more about how to craft multiple payloads in the GenerateBatch() function
// signedPayloads, err := contract.Signature.GenerateBatch(payloads)
// tx, err := contract.Signature.MintBatch(context.Background(), signedPayloads)
func (signature *ERC721SignatureMinting) MintBatch(ctx context.Context, signedPayloads []*SignedPayload721) (*types.Transaction, error) {
if signature.isLegacyContract(ctx) {
contractPayloads := []*abi.ITokenERC721MintRequest{}
for _, signedPayload := range signedPayloads {
price, ok := big.NewInt(0).SetString(signedPayload.Payload.Price, 10)
if !ok {
return nil, errors.New("Specified price was not a valid big.Int")
}
if price.Cmp(big.NewInt(0)) == 1 {
return nil, fmt.Errorf("Can only batch free mints. For mints with a price, use the Mint() function.")
}
payload, err := mapLegacyPayloadToContractStruct(signedPayload.Payload)
if err != nil {
return nil, err
}
contractPayloads = append(contractPayloads, payload)
}
encoded := [][]byte{}
for i, payload := range contractPayloads {
txOpts, err := signature.Helper.getEncodedTxOptions(ctx)
if err != nil {
return nil, err
}
signatureBytes, err := hex.DecodeString(signedPayloads[i].Signature[2:])
if err != nil {
return nil, err
}
tx, err := signature.legacy.MintWithSignature(txOpts, *payload, signatureBytes)
if err != nil {
return nil, err
}
encoded = append(encoded, tx.Data())
}
txOpts, err := signature.Helper.GetTxOptions(ctx)
if err != nil {
return nil, err
}
tx, err := signature.legacy.Multicall(txOpts, encoded)
if err != nil {
return nil, err
}
return signature.Helper.AwaitTx(ctx, tx.Hash())
} else {
contractPayloads := []*abi.ISignatureMintERC721MintRequest{}
for _, signedPayload := range signedPayloads {
price, ok := big.NewInt(0).SetString(signedPayload.Payload.Price, 10)
if !ok {
return nil, errors.New("Specified price was not a valid big.Int")
}
if price.Cmp(big.NewInt(0)) == 1 {
return nil, fmt.Errorf("Can only batch free mints. For mints with a price, use the Mint() function.")
}
payload, err := mapPayloadToContractStruct(signedPayload.Payload)
if err != nil {
return nil, err
}
contractPayloads = append(contractPayloads, payload)
}
encoded := [][]byte{}
for i, payload := range contractPayloads {
txOpts, err := signature.Helper.getEncodedTxOptions(ctx)
if err != nil {
return nil, err
}
signatureBytes, err := hex.DecodeString(signedPayloads[i].Signature[2:])
if err != nil {
return nil, err
}
tx, err := signature.extension.MintWithSignature(txOpts, *payload, signatureBytes)
if err != nil {
return nil, err
}
encoded = append(encoded, tx.Data())
}
txOpts, err := signature.Helper.GetTxOptions(ctx)
if err != nil {
return nil, err
}
// TODO: This should throw if you don't have multicall on contract
tx, err := signature.legacy.Multicall(txOpts, encoded)
if err != nil {
return nil, err
}
return signature.Helper.AwaitTx(ctx, tx.Hash())
}
}
// Verify that a signed payload is valid
//
// signedPayload: the payload to verify
//
// returns: true if the payload is valid, otherwise false.
//
// Example
//
// // Learn more about how to craft a payload in the Generate() function
// signedPayload, err := contract.Signature.Generate(payload)
// isValid, err := contract.Signature.Verify(signedPayload)
func (signature *ERC721SignatureMinting) Verify(ctx context.Context, signedPayload *SignedPayload721) (bool, error) {
mintRequest := signedPayload.Payload
mintSignatureBytes, err := hex.DecodeString(signedPayload.Signature[2:])
if err != nil {
return false, err
}
if signature.isLegacyContract(ctx) {
message, err := mapLegacyPayloadToContractStruct(mintRequest)
if err != nil {
return false, err
}
verification, _, err := signature.legacy.Verify(&bind.CallOpts{Context: ctx}, *message, mintSignatureBytes)
return verification, err
} else {
message, err := mapPayloadToContractStruct(mintRequest)
if err != nil {
return false, err
}
verification, err := signature.extension.Verify(&bind.CallOpts{Context: ctx}, *message, mintSignatureBytes)
return verification.Success, err
}
}
// Generate a new payload from the given data
//
// payloadToSign: the payload containing the data for the signature mint
//
// returns: the payload signed by the minter's private key
//
// Example
//
// payload := &thirdweb.Signature721PayloadInput{
// To: "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6", // address to mint to
// Price: 0, // cost of minting
// CurrencyAddress: "0x0000000000000000000000000000000000000000", // currency to pay in order to mint
// MintStartTime: 0, // time where minting is allowed to start (epoch seconds)
// MintEndTime: 100000000000000, // time when this signature expires (epoch seconds)
// PrimarySaleRecipient: "0x0000000000000000000000000000000000000000", // address to receive the primary sales of this mint
// Metadata: &thirdweb.NFTMetadataInput{ // metadata of the NFT to mint
// Name: "ERC721 Sigmint!",
// },
// RoyaltyRecipient: "0x0000000000000000000000000000000000000000", // address to receive royalties of this mint
// RoyaltyBps: 0, // royalty cut of this mint in basis points
// }
//
// signedPayload, err := contract.Signature.Generate(payload)
func (signature *ERC721SignatureMinting) Generate(ctx context.Context, payloadToSign *Signature721PayloadInput) (*SignedPayload721, error) {
payload, err := signature.GenerateBatch(ctx, []*Signature721PayloadInput{payloadToSign})
if err != nil {
return nil, err
}
return payload[0], nil
}
// Generate a batch of new payload from the given data
//
// payloadToSign: the payloads containing the data for the signature mint
//
// returns: the payloads signed by the minter's private key
//
// Example
//
// payload := []*thirdweb.Signature721PayloadInput{
// &thirdweb.Signature721PayloadInput{
// To: "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
// Price: 0,
// CurrencyAddress: "0x0000000000000000000000000000000000000000",
// MintStartTime: 0,
// MintEndTime: 100000000000000,
// PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
// Metadata: &thirdweb.NFTMetadataInput{
// Name: "ERC721 Sigmint!",
// Image: imageFile,
// },
// RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
// RoyaltyBps: 0,
// },
// &thirdweb.Signature721PayloadInput{
// To: "0x9e1b8A86fFEE4a7175DAE4bDB1cC12d111Dcb3D6",
// Price: 0,
// CurrencyAddress: "0x0000000000000000000000000000000000000000",
// MintStartTime: 0,
// MintEndTime: 100000000000000,
// PrimarySaleRecipient: "0x0000000000000000000000000000000000000000",
// Metadata: &thirdweb.NFTMetadataInput{
// Name: "ERC721 Sigmint!",
// Image: imageFile,
// },
// RoyaltyRecipient: "0x0000000000000000000000000000000000000000",
// RoyaltyBps: 0,
// },
// }
//
// signedPayload, err := contract.Signature.GenerateBatch(context.Background(), payload)
func (signature *ERC721SignatureMinting) GenerateBatch(ctx context.Context, payloadsToSign []*Signature721PayloadInput) ([]*SignedPayload721, error) {
// TODO: Verify roles and return error
metadatas := []*NFTMetadataInput{}
for _, payload := range payloadsToSign {
metadatas = append(metadatas, payload.Metadata)
}
uris, err := uploadOrExtractUris(ctx, metadatas, signature.storage)
if err != nil {
return nil, err
}
signedPayloads := []*SignedPayload721{}
for i, uri := range uris {
p := payloadsToSign[i]
generatedId := uuid.New()
id := [32]byte{}
for i := 0; i < 16; i++ {
id[16+i] = generatedId[i]
}
provider := signature.Helper.GetProvider()
price, err := normalizePriceValue(ctx, provider, p.Price, p.CurrencyAddress)
if err != nil {
return nil, err
}
payload := &Signature721PayloadOutput{
To: p.To,
Price: price.String(),
CurrencyAddress: p.CurrencyAddress,
MintStartTime: p.MintStartTime,
MintEndTime: p.MintEndTime,
PrimarySaleRecipient: p.PrimarySaleRecipient,
RoyaltyRecipient: p.RoyaltyRecipient,
RoyaltyBps: p.RoyaltyBps,
Uri: uri,
Uid: id,
}
typedData, err := signature.generateMessage(ctx, payload)
if err != nil {
return nil, err
}
domainSeparator, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map())
if err != nil {
return nil, err
}
typedDataHash, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message)
if err != nil {
return nil, err
}
rawData := []byte(fmt.Sprintf("\x19\x01%s%s", string(domainSeparator), string(typedDataHash)))
sigHash := crypto.Keccak256(rawData)
privateKey := signature.Helper.GetPrivateKey()
signatureHash, err := crypto.Sign(sigHash, privateKey)
if err != nil {
return nil, err
}
// We need this to correct v = 0,1 to v = 27,28 - or else all will break
if signatureHash[64] == 0 || signatureHash[64] == 1 {
signatureHash[64] += 27
}
signedPayloads = append(signedPayloads, &SignedPayload721{
Payload: payload,
Signature: "0x" + hex.EncodeToString(signatureHash),
})
}
return signedPayloads, nil
}
func (signature *ERC721SignatureMinting) GenerateBatchWithUris(ctx context.Context, payloadsToSign []*Signature721PayloadInputWithUri) ([]*SignedPayload721, error) {
// TODO: Verify roles and return error
signedPayloads := []*SignedPayload721{}
for _, p := range payloadsToSign {
generatedId := uuid.New()
id := [32]byte{}
for i := 0; i < 16; i++ {
id[16+i] = generatedId[i]
}
provider := signature.Helper.GetProvider()
price, err := normalizePriceValue(ctx, provider, p.Price, p.CurrencyAddress)
if err != nil {
return nil, err
}
payload := &Signature721PayloadOutput{
To: p.To,
Price: price.String(),
CurrencyAddress: p.CurrencyAddress,
MintStartTime: p.MintStartTime,
MintEndTime: p.MintEndTime,
PrimarySaleRecipient: p.PrimarySaleRecipient,
RoyaltyRecipient: p.RoyaltyRecipient,
RoyaltyBps: p.RoyaltyBps,
Uri: p.MetadataUri,
Uid: id,
}
typedData, err := signature.generateMessage(ctx, payload)
if err != nil {
return nil, err
}
domainSeparator, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map())
if err != nil {
return nil, err
}
typedDataHash, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message)
if err != nil {
return nil, err
}
rawData := []byte(fmt.Sprintf("\x19\x01%s%s", string(domainSeparator), string(typedDataHash)))
sigHash := crypto.Keccak256(rawData)
privateKey := signature.Helper.GetPrivateKey()
signatureHash, err := crypto.Sign(sigHash, privateKey)
if err != nil {
return nil, err
}
// We need this to correct v = 0,1 to v = 27,28 - or else all will break
if signatureHash[64] == 0 || signatureHash[64] == 1 {
signatureHash[64] += 27
}
signedPayloads = append(signedPayloads, &SignedPayload721{
Payload: payload,
Signature: "0x" + hex.EncodeToString(signatureHash),
})
}
return signedPayloads, nil
}
func (signature *ERC721SignatureMinting) generateMessage(ctx context.Context, mintRequest *Signature721PayloadOutput) (*signerTypes.TypedData, error) {
chainId, err := signature.Helper.GetChainID(ctx)
if err != nil {
return nil, err
}
if signature.isLegacyContract(ctx) {
message := signerTypes.TypedDataMessage{
"to": mintRequest.To,
"royaltyRecipient": mintRequest.RoyaltyRecipient,
"royaltyBps": fmt.Sprintf("%v", mintRequest.RoyaltyBps),
"primarySaleRecipient": mintRequest.PrimarySaleRecipient,
"uri": mintRequest.Uri,
"price": fmt.Sprintf("%v", mintRequest.Price),
"currency": mintRequest.CurrencyAddress,
"validityStartTimestamp": fmt.Sprintf("%v", mintRequest.MintStartTime),
"validityEndTimestamp": fmt.Sprintf("%v", mintRequest.MintEndTime),
"uid": mintRequest.Uid[:],
}
typedData := signerTypes.TypedData{
Types: signerTypes.Types{
"MintRequest": []signerTypes.Type{
{Name: "to", Type: "address"},
{Name: "royaltyRecipient", Type: "address"},
{Name: "royaltyBps", Type: "uint256"},
{Name: "primarySaleRecipient", Type: "address"},
{Name: "uri", Type: "string"},
{Name: "price", Type: "uint256"},
{Name: "currency", Type: "address"},
{Name: "validityStartTimestamp", Type: "uint128"},
{Name: "validityEndTimestamp", Type: "uint128"},
{Name: "uid", Type: "bytes32"},
},
"EIP712Domain": []signerTypes.Type{
{Name: "name", Type: "string"},
{Name: "version", Type: "string"},
{Name: "chainId", Type: "uint256"},
{Name: "verifyingContract", Type: "address"},
},
},
PrimaryType: "MintRequest",
Domain: signerTypes.TypedDataDomain{
Name: "TokenERC721",
Version: "1",
ChainId: math.NewHexOrDecimal256(chainId.Int64()),
VerifyingContract: signature.Helper.getAddress().String(),
},
Message: message,
}
return &typedData, nil
} else {
message := signerTypes.TypedDataMessage{
"to": mintRequest.To,
"royaltyRecipient": mintRequest.RoyaltyRecipient,
"royaltyBps": fmt.Sprintf("%v", mintRequest.RoyaltyBps),
"quantity": fmt.Sprintf("%v", 1),
"primarySaleRecipient": mintRequest.PrimarySaleRecipient,
"uri": mintRequest.Uri,
"pricePerToken": fmt.Sprintf("%v", mintRequest.Price),
"currency": mintRequest.CurrencyAddress,
"validityStartTimestamp": fmt.Sprintf("%v", mintRequest.MintStartTime),
"validityEndTimestamp": fmt.Sprintf("%v", mintRequest.MintEndTime),
"uid": mintRequest.Uid[:],
}
typedData := signerTypes.TypedData{
Types: signerTypes.Types{
"MintRequest": []signerTypes.Type{
{Name: "to", Type: "address"},
{Name: "royaltyRecipient", Type: "address"},
{Name: "royaltyBps", Type: "uint256"},
{Name: "primarySaleRecipient", Type: "address"},
{Name: "uri", Type: "string"},
{Name: "quantity", Type: "uint256"},
{Name: "pricePerToken", Type: "uint256"},
{Name: "currency", Type: "address"},
{Name: "validityStartTimestamp", Type: "uint128"},
{Name: "validityEndTimestamp", Type: "uint128"},
{Name: "uid", Type: "bytes32"},
},
"EIP712Domain": []signerTypes.Type{
{Name: "name", Type: "string"},
{Name: "version", Type: "string"},
{Name: "chainId", Type: "uint256"},
{Name: "verifyingContract", Type: "address"},
},
},
PrimaryType: "MintRequest",
Domain: signerTypes.TypedDataDomain{
Name: "SignatureMintERC721",
Version: "1",
ChainId: math.NewHexOrDecimal256(chainId.Int64()),
VerifyingContract: signature.Helper.getAddress().String(),
},
Message: message,
}
return &typedData, nil
}
}
func (signature *ERC721SignatureMinting) isLegacyContract(ctx context.Context) bool {
contractType, err := signature.legacy.ContractType(&bind.CallOpts{
Context: ctx,
})
if err != nil {
return false
}
// If contractType = TokenERC721
return hex.EncodeToString(contractType[:]) == "546f6b656e455243373231000000000000000000000000000000000000000000"
}
func mapLegacyPayloadToContractStruct(mintRequest *Signature721PayloadOutput) (*abi.ITokenERC721MintRequest, error) {
price, ok := big.NewInt(0).SetString(mintRequest.Price, 10)
if !ok {
return nil, errors.New("Specified price was not a valid big.Int")
}
return &abi.ITokenERC721MintRequest{
To: common.HexToAddress(mintRequest.To),
RoyaltyRecipient: common.HexToAddress(mintRequest.RoyaltyRecipient),
RoyaltyBps: big.NewInt(int64(mintRequest.RoyaltyBps)),
PrimarySaleRecipient: common.HexToAddress(mintRequest.PrimarySaleRecipient),
Uri: mintRequest.Uri,
Price: price,
Currency: common.HexToAddress(mintRequest.CurrencyAddress),
ValidityStartTimestamp: big.NewInt(int64(mintRequest.MintStartTime)),
ValidityEndTimestamp: big.NewInt(int64(mintRequest.MintEndTime)),
Uid: mintRequest.Uid,
}, nil
}
func mapPayloadToContractStruct(mintRequest *Signature721PayloadOutput) (*abi.ISignatureMintERC721MintRequest, error) {
price, ok := big.NewInt(0).SetString(mintRequest.Price, 10)
if !ok {
return nil, errors.New("Specified price was not a valid big.Int")
}
return &abi.ISignatureMintERC721MintRequest{
To: common.HexToAddress(mintRequest.To),
RoyaltyRecipient: common.HexToAddress(mintRequest.RoyaltyRecipient),
RoyaltyBps: big.NewInt(int64(mintRequest.RoyaltyBps)),
PrimarySaleRecipient: common.HexToAddress(mintRequest.PrimarySaleRecipient),
Uri: mintRequest.Uri,
Quantity: big.NewInt(1), // Always has quantity of 1
PricePerToken: price,
Currency: common.HexToAddress(mintRequest.CurrencyAddress),
ValidityStartTimestamp: big.NewInt(int64(mintRequest.MintStartTime)),
ValidityEndTimestamp: big.NewInt(int64(mintRequest.MintEndTime)),
Uid: mintRequest.Uid,
}, nil
}