Skip to content

Commit 9bf944c

Browse files
committed
update
1 parent 50eb339 commit 9bf944c

File tree

7 files changed

+107
-15
lines changed

7 files changed

+107
-15
lines changed

Assets/Shared/Scripts/UI/LevelCompleteScreen.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ private async UniTask MintCoins()
168168
{
169169
// Calculate the quantity to mint
170170
// Need to take into account Immutable Runner Token decimal value i.e. 18
171-
BigInteger quantity = BigInteger.Multiply(new BigInteger(m_CoinCount), BigInteger.Pow(10, 18));
171+
BigInteger quantity = new BigInteger(m_CoinCount);
172172
Debug.Log($"Quantity: {quantity}");
173173
var nvc = new List<KeyValuePair<string, string>>
174174
{

Assets/Shared/Scripts/UI/MintScreen.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private async UniTask<bool> MintCoins()
170170
{
171171
// Calculate the quantity to mint
172172
// Need to take into account Immutable Runner Token decimal value i.e. 18
173-
BigInteger quantity = BigInteger.Multiply(new BigInteger(coinsCollected), BigInteger.Pow(10, 18));
173+
BigInteger quantity = new BigInteger(coinsCollected);
174174
Debug.Log($"Quantity: {quantity}");
175175
var nvc = new List<KeyValuePair<string, string>> {
176176
// Set 'to' to the player's wallet address

Assets/Shared/Scripts/UI/UnlockedSkinScreen.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private async void Craft()
136136
m_CraftState = CraftSkinState.Crafting;
137137

138138
// Burn tokens and mint a new skin i.e. crafting a skin
139-
const string runnerTokenContractAddress = "0xd14983206B7f2348b976878cCF097E55E1461977";
139+
const string runnerTokenContractAddress = "0x3b28c82a6e5e3d6023e2a440b2b1b3480d4c6fd3";
140140

141141
try {
142142
TransactionReceiptResponse response = await Passport.Instance.ZkEvmSendTransactionWithConfirmation(new TransactionRequest()
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright Immutable Pty Ltd 2018 - 2023
2+
// SPDX-License-Identifier: Apache 2.0
3+
pragma solidity 0.8.19;
4+
5+
import "@imtbl/contracts/contracts/token/erc1155/preset/ImmutableERC1155.sol";
6+
import "@imtbl/contracts/contracts/token/erc721/preset/ImmutableERC721.sol";
7+
8+
9+
/**
10+
* @title ImmutableERC1155
11+
* @author @jasonzwli, Immutable
12+
*/
13+
contract RunnerToken1155 is ImmutableERC1155 {
14+
/// ===== Constructor =====
15+
uint256 public constant FOXTOKENID = 1;
16+
uint256 public constant COINTOKENID = 2;
17+
18+
// A reference to the Immutable Runner Skin contract for the craftSkin function to use.
19+
// Note: Immutable Runner Skin contract simply extends ImmutableERC721, so we can set
20+
// the type to ImmutableERC721
21+
ImmutableERC721 private _skinContract;
22+
23+
/**
24+
* @notice Grants `DEFAULT_ADMIN_ROLE` to the supplied `owner` address
25+
*
26+
* Sets the name and symbol for the collection
27+
* Sets the default admin to `owner`
28+
* Sets the `baseURI`
29+
* Sets the royalty receiver and amount (this can not be changed once set)
30+
* @param owner The address that will be granted the `DEFAULT_ADMIN_ROLE`
31+
* @param name_ The name of the collection
32+
* @param baseURI_ The base URI for the collection
33+
* @param contractURI_ The contract URI for the collection
34+
* @param _operatorAllowlist The address of the OAL
35+
* @param _receiver The address that will receive the royalty payments
36+
* @param _feeNumerator The percentage of the sale price that will be paid as a royalty
37+
*/
38+
constructor(
39+
address owner,
40+
string memory name_,
41+
string memory baseURI_,
42+
string memory contractURI_,
43+
address _operatorAllowlist,
44+
address _receiver,
45+
uint96 _feeNumerator,
46+
address skinContractAddr
47+
) ImmutableERC1155(owner, name_, baseURI_, contractURI_, _operatorAllowlist, _receiver, _feeNumerator) {
48+
// Grant the contract deployer the default admin role: it will be able
49+
// to grant and revoke any roles
50+
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
51+
// Save the Immutable Runner Skin contract address
52+
_skinContract = ImmutableERC721(skinContractAddr);
53+
54+
// Uncomment the line below to grant minter role to contract deployer
55+
_grantRole(MINTER_ROLE, msg.sender);
56+
}
57+
58+
function mintNFT(address to) external onlyRole(MINTER_ROLE) {
59+
super._mint(to, FOXTOKENID, 1, "");
60+
}
61+
62+
function mintCoins(address to, uint256 quantity) external onlyRole(MINTER_ROLE) {
63+
super._mint(to, COINTOKENID, quantity, "");
64+
}
65+
66+
// Burns three tokens and crafts a skin to the caller
67+
function craftSkin() external {
68+
require(
69+
balanceOf(msg.sender, COINTOKENID) >= 3,
70+
"craftSkin: Caller does not have enough tokens"
71+
);
72+
73+
// Burn caller's three tokens
74+
_burn(msg.sender, COINTOKENID, 3);
75+
76+
// Mint one Immutable Runner Skin to the caller
77+
// Note: To mint a skin, the Immutable Runner Token contract must have the
78+
// Immutable Runner Skin contract minter role.
79+
_skinContract.mintByQuantity(msg.sender, 1);
80+
}
81+
}

contracts/scripts/deploy.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,22 @@ import { ethers } from 'hardhat'; // eslint-disable-line import/no-extraneous-de
22

33
async function main() {
44
// Load the Immutable Runner Tokencontract and get the contract factory
5-
const contractFactory = await ethers.getContractFactory('RunnerToken');
5+
const contractFactory = await ethers.getContractFactory('RunnerToken1155');
66

77
// Deploy the contract to the zkEVM network
8+
const ownerEthAddress = ""
9+
const collectionName = "Immutable Runner Fox 1155"
10+
const baseURI = "https://immutable-runner-json-server-0q8u.onrender.com/fox/"
11+
const contractURI = "https://crimson-specified-vicuna-718.mypinata.cloud/ipfs/QmY7zUHJ6ti3Vg1NPBEjpsNELaMrHvJLwyXQzRd1Pjj68H"
812
const contract = await contractFactory.deploy(
9-
'YOUR_IMMUTABLE_RUNNER_SKIN_CONTRACT_ADDRESS', // Immutable Runner Skin contract address
13+
ownerEthAddress,
14+
collectionName,
15+
baseURI,
16+
contractURI, // contract / collection metadata URI
17+
"0x6b969FD89dE634d8DE3271EbE97734FEFfcd58eE", // operator allow list https://docs.immutable.com/products/zkevm/contracts/erc721/#operator-allowlist-royalty-and-protocol-fee-enforcement
18+
ownerEthAddress, // royalty recipient
19+
5, // royalty fee percentage
20+
"0x9b74823f4bcbcb3e0f74cadc3a1d2552a18777ed" // Immutable Runner Skin contract address
1021
);
1122

1223
console.log('Contract deployed to:', await contract.getAddress());

mint-backend/dest/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ router.post('/mint/fox', async (req, res) => {
4040
// Connect to wallet with minter role
4141
const signer = new ethers_1.Wallet(privateKey).connect(zkEvmProvider);
4242
// Specify the function to call
43-
const abi = ['function mintByQuantity(address to, uint256 quantity)'];
43+
const abi = ["function mintNFT(address to)"];
4444
// Connect contract to the signer
4545
const contract = new ethers_1.Contract(foxContractAddress, abi, signer);
46-
// Mints the number of tokens specified
47-
const tx = await contract.mintByQuantity(to, quantity, gasOverrides);
46+
// Mints 1 fox NFT
47+
const tx = await contract.mintNFT(to, gasOverrides);
4848
await tx.wait();
4949
res.writeHead(200);
5050
res.end(JSON.stringify({ message: "Minted foxes" }));
@@ -72,11 +72,11 @@ router.post('/mint/token', async (req, res) => {
7272
// Connect to wallet with minter role
7373
const signer = new ethers_1.Wallet(privateKey).connect(zkEvmProvider);
7474
// Specify the function to call
75-
const abi = ['function mint(address to, uint256 quantity)'];
75+
const abi = ["function mintCoins(address to, uint256 quantity)"];
7676
// Connect contract to the signer
7777
const contract = new ethers_1.Contract(tokenContractAddress, abi, signer);
7878
// Mints the number of tokens specified
79-
const tx = await contract.mint(to, quantity, gasOverrides);
79+
const tx = await contract.mintCoins(to, quantity, gasOverrides);
8080
await tx.wait();
8181
res.writeHead(200);
8282
res.end(JSON.stringify({ message: "Minted ERC20 tokens" }));

mint-backend/src/index.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ router.post('/mint/fox', async (req: Request, res: Response) => {
4848
const signer = new Wallet(privateKey).connect(zkEvmProvider);
4949

5050
// Specify the function to call
51-
const abi = ['function mintByQuantity(address to, uint256 quantity)'];
51+
const abi = ["function mintNFT(address to)"];
5252
// Connect contract to the signer
5353
const contract = new Contract(foxContractAddress, abi, signer);
5454

55-
// Mints the number of tokens specified
56-
const tx = await contract.mintByQuantity(to, quantity, gasOverrides);
55+
// Mints 1 fox NFT
56+
const tx = await contract.mintNFT(to, gasOverrides);
5757
await tx.wait();
5858

5959
res.writeHead(200);
@@ -83,12 +83,12 @@ router.post('/mint/token', async (req: Request, res: Response) => {
8383
const signer = new Wallet(privateKey).connect(zkEvmProvider);
8484

8585
// Specify the function to call
86-
const abi = ['function mint(address to, uint256 quantity)'];
86+
const abi = ["function mintCoins(address to, uint256 quantity)"];
8787
// Connect contract to the signer
8888
const contract = new Contract(tokenContractAddress, abi, signer);
8989

9090
// Mints the number of tokens specified
91-
const tx = await contract.mint(to, quantity, gasOverrides);
91+
const tx = await contract.mintCoins(to, quantity, gasOverrides);
9292
await tx.wait();
9393

9494
res.writeHead(200);

0 commit comments

Comments
 (0)