Mint Game Items (ERC1155) 🏹
Minting game items is very easy through Sidekick:
Go to Sequence Builder and deploy a new Web3 Game Items contract, don't forget to set the contract owner to your Sidekick smart wallet address.
Start Sidekick with Docker
Make sure Sidekick is up and running, read more about it here.
pnpm docker:start
Mint 1 game item to 10 users, programatically.
import { ethers } from "ethers"
const contractAddress = '0x' // Your contract address
const chainId = 421614 // Arbitrum Sepolia
const mintGameItems = async (chainId: number, contractAddress: string) => {
const users = Array.from({ length: 10 }, () => ethers.Wallet.createRandom().address)
const itemTypes = Array.from({ length: 10 }, () => Math.floor(Math.random() * 5) + 1)
const itemAmounts = Array.from({ length: 10 }, () => Math.floor(Math.random() * 10) + 1)
const itemDatas = Array(10).fill('0x')
const response = await fetch(`http://127.0.0.1:3000/write/erc1155/${chainId}/${contractAddress}/mintBatch`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-secret-key': process.env.SECRET_KEY || ''
},
body: JSON.stringify({
recipients: users,
ids: itemTypes,
amounts: itemAmounts,
datas: itemDatas
})
})
const data = await response.json()
console.log(data)
}
mintGameItems(chainId, contractAddress)
Inspect the response data
{
result: {
txHash: "0x...",
txUrl: "https://sepolia.arbiscan.io//tx/0x...",
},
}