diff --git a/src/abi/main.json b/src/abi/main.json new file mode 100644 index 0000000..2322c65 --- /dev/null +++ b/src/abi/main.json @@ -0,0 +1,251 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "assembleBombs", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "bombBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bombPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "boomerBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boomerPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "mailbomb", + "outputs": [ + { + "internalType": "contract Mailbomb", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "radicalizeBoomers", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "sendBombs", + "outputs": [ + { + "internalType": "bool[]", + "name": "results", + "type": "bool[]" + }, + { + "internalType": "uint256[]", + "name": "tokensKilled", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setBombPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_price", + "type": "uint256" + } + ], + "name": "setBoomerPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "setMailbombContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_address", + "type": "address" + } + ], + "name": "setUnaboomerContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unaboomer", + "outputs": [ + { + "internalType": "contract Unaboomer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/template/Sections.jsx b/src/template/Sections.jsx index 0b40c84..16fa489 100644 --- a/src/template/Sections.jsx +++ b/src/template/Sections.jsx @@ -1,5 +1,6 @@ import React, { useState } from 'react'; import { ethers } from 'ethers'; +import { useAccount, useContractReads, usePrepareContractWrite, useContractWrite } from 'wagmi'; import Typewriter from 'react-ts-typewriter'; import Slider from 'rc-slider'; import { Parallax } from 'react-parallax'; @@ -12,11 +13,15 @@ import Newspapers from '../img/newspapers.png'; import Bomb from '../img/bomb.png'; import Explosion from '../img/explosion.png'; import SeizedItems from '../img/seizeditems.png'; +import MainABI from '../abi/main.json'; import 'rc-slider/assets/index.css'; import '../styles/sections.css'; +const contractAddress = '0x5FbDB2315678afecb367f032d93F642f64180aa3'; + + export class Section1 extends React.Component { constructor(props) { super(props); @@ -63,34 +68,75 @@ export function Section3() { const [boomerAmount, setBoomerAmount] = useState(1); const [bombAmount, setBombAmount] = useState(1); const [sendBombAmount, setSendBombAmount] = useState(1); - const price = ethers.utils.parseEther('.01'); - - console.log(bombAmount) + const [boomerPrice, setBoomerPrice] = useState(0); + const [bombPrice, setBombPrice] = useState(0); + const [boomerBalance, setBoomerBalance] = useState(0); + const [bombBalance, setBombBalance] = useState(0); + const { isConnected, address } = useAccount(); + useContractReads({ + contracts: [ + { + address: contractAddress, + abi: MainABI, + enabled: isConnected, + functionName: 'boomerPrice' + }, + { + address: contractAddress, + abi: MainABI, + enabled: isConnected, + functionName: 'bombPrice' + }, + { + address: contractAddress, + abi: MainABI, + enabled: isConnected, + functionName: 'boomerBalance', + args: [address] + }, + { + address: contractAddress, + abi: MainABI, + enabled: isConnected, + functionName: 'bombBalance', + args: [address] + } + ], + onSuccess(data) { + setBoomerPrice(data[0].toString()); + setBombPrice(data[1].toString()); + setBoomerBalance(data[2].toString()); + setBombBalance(data[3].toString()); + } + + }); return (
+ {isConnected &&

Radicalize a Boomer

Radicalizing a boomer will mint ERC-721 BOOMR tokens with images of a pixel art Unabomber - a Web3 Unaboomer.

+

You have {boomerBalance} BOOMR

- mint {boomerAmount} ({ethers.utils.formatEther((price * boomerAmount).toString())} Ξ) + mint {boomerAmount} ({ethers.utils.formatEther((boomerPrice * boomerAmount).toString())} Ξ)

setBoomerAmount(v)} /> -

Assemble Bombs

-

Assembling bombs will mint ERC-1155 BOMB tokens with an image of a pixel art bomb - send to other Unaboomers to kill them.

+

Assembling bombs will mint ERC-1155 BOMB tokens with an image of a pixel art bomb - send to random Unaboomers to kill them.

+

You have {bombBalance} BOMB

- mint {bombAmount} ({ethers.utils.formatEther((price * bombAmount).toString())} Ξ) + mint {bombAmount} ({ethers.utils.formatEther((bombPrice * bombAmount).toString())} Ξ)

Send Bombs

-

Sending bombs will burn your BOMB token and kill a BOOMR token at random. Be careful not to kill yourself in the process!

+

Sending bombs will burn your BOMB token and kill a BOOMR token at random. Be careful not to kill yourself in the process.

+

There are 123 BOOMR available to kill

- + send {sendBombAmount} (~0 Ξ)

@@ -113,6 +160,11 @@ export function Section3() { }} onChange={v => setSendBombAmount(v)} />
+ || +
+

connect your wallet to play

+
+ }
) }