-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMintTransactions.ts
48 lines (45 loc) · 1.61 KB
/
MintTransactions.ts
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
const sendMintRandomNftTransaction = async (numberOfTokensToMint: number) => {
const mintRandomNftTransaction = {
value: tokenPrice * numberOfTokensToMint,
data: 'mintRandomNft',
receiver: contractAddress,
gasLimit: 10000000 * numberOfTokensToMint
};
await refreshAccount();
const { sessionId /*, error*/ } = await sendTransactions({
transactions: mintRandomNftTransaction,
transactionsDisplayInfo: {
processingMessage: 'Message to display while transaction is processing',
errorMessage: 'Message to display if transaction failed',
successMessage: 'Message to display if transaction succeeded'
},
redirectAfterSign: false
});
if (sessionId != null) {
setTransactionSessionId(sessionId);
}
};
const sendMintSpecificNftTransaction = async (nonceOfMintedNft: string) => {
//nonceOfMintedNft should be in hexa
//nonceOfMintedNft should have an even number of characters
//(pad with a 0 at the beginning if it does not)
const mintRandomNftTransaction = {
value: tokenPrice,
data: `mintSpecificNft@${nonceOfMintedNft}`,
receiver: contractAddress,
gasLimit: 10000000
};
await refreshAccount();
const { sessionId /*, error*/ } = await sendTransactions({
transactions: mintRandomNftTransaction,
transactionsDisplayInfo: {
processingMessage: 'Message to display while transaction is processing',
errorMessage: 'Message to display if transaction failed',
successMessage: 'Message to display if transaction succeeded'
},
redirectAfterSign: false
});
if (sessionId != null) {
setTransactionSessionId(sessionId);
}
};