const nftAddress = "0xf7f236506f5f185dc46135a8c35f6f55e83e56f0"; const NFTManagerABI = [ { inputs: [], stateMutability: "payable", type: "constructor", }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "nftContract", type: "address", }, { indexed: false, internalType: "uint256", name: "tokenId", type: "uint256", }, { indexed: false, internalType: "string", name: "name", type: "string", }, { indexed: false, internalType: "address", name: "storeAddress", type: "address", }, { indexed: false, internalType: "address", name: "owner", type: "address", }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256", }, { indexed: false, internalType: "string", name: "store", type: "string", }, ], name: "NFTListed", type: "event", }, { anonymous: false, inputs: [ { indexed: false, internalType: "address", name: "nftContract", type: "address", }, { indexed: false, internalType: "uint256", name: "tokenId", type: "uint256", }, { indexed: false, internalType: "string", name: "name", type: "string", }, { indexed: false, internalType: "address", name: "storeAddress", type: "address", }, { indexed: false, internalType: "address", name: "owner", type: "address", }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256", }, { indexed: false, internalType: "string", name: "store", type: "string", }, ], name: "NFTSold", type: "event", }, { inputs: [ { internalType: "string", name: "store", type: "string", }, { internalType: "address", name: "storeAddress", type: "address", }, ], name: "addStore", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "address", name: "_nftContract", type: "address", }, { internalType: "uint256", name: "_tokenId", type: "uint256", }, { internalType: "uint256", name: "_amount", type: "uint256", }, ], name: "approveTransaction", outputs: [], stateMutability: "payable", type: "function", }, { inputs: [ { internalType: "address", name: "_nftContract", type: "address", }, { internalType: "uint256", name: "_tokenId", type: "uint256", }, ], name: "cancelTransaction", outputs: [], stateMutability: "payable", type: "function", }, { inputs: [], name: "getAllStores", outputs: [ { components: [ { internalType: "string", name: "storeName", type: "string", }, { internalType: "address", name: "storeAddress", type: "address", }, ], internalType: "struct NFTManager.storeDetails[]", name: "", type: "tuple[]", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getBalance", outputs: [ { internalType: "uint256", name: "", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getMyActiveTransactions", outputs: [ { components: [ { internalType: "address", name: "nftContract", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, { internalType: "string", name: "name", type: "string", }, { internalType: "address payable", name: "storeAddress", type: "address", }, { internalType: "address payable", name: "owner", type: "address", }, { internalType: "uint256", name: "amount", type: "uint256", }, { internalType: "string", name: "store", type: "string", }, ], internalType: "struct NFTManager.NFT[]", name: "", type: "tuple[]", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "storeAddress", type: "address", }, ], name: "getStoreActiveTransactions", outputs: [ { components: [ { internalType: "address", name: "nftContract", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, { internalType: "string", name: "name", type: "string", }, { internalType: "address payable", name: "storeAddress", type: "address", }, { internalType: "address payable", name: "owner", type: "address", }, { internalType: "uint256", name: "amount", type: "uint256", }, { internalType: "string", name: "store", type: "string", }, ], internalType: "struct NFTManager.NFT[]", name: "", type: "tuple[]", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "_nftContract", type: "address", }, { internalType: "string", name: "name", type: "string", }, { internalType: "uint256", name: "_tokenId", type: "uint256", }, { internalType: "uint256", name: "_amount", type: "uint256", }, { internalType: "address payable", name: "_storeAddress", type: "address", }, { internalType: "string", name: "store", type: "string", }, ], name: "initTransaction", outputs: [], stateMutability: "payable", type: "function", }, { inputs: [ { internalType: "uint256", name: "", type: "uint256", }, ], name: "stores", outputs: [ { internalType: "string", name: "storeName", type: "string", }, { internalType: "address", name: "storeAddress", type: "address", }, ], stateMutability: "view", type: "function", }, ]; const walleyAddress = "0x055599f29bd2ae4c4abda83d91a4f6ca390eca11"; const WalleyABI = [ { inputs: [ { internalType: "address", name: "_marketplaceContract", type: "address", }, ], stateMutability: "nonpayable", type: "constructor", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "owner", type: "address", }, { indexed: true, internalType: "address", name: "approved", type: "address", }, { indexed: true, internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "Approval", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "owner", type: "address", }, { indexed: true, internalType: "address", name: "operator", type: "address", }, { indexed: false, internalType: "bool", name: "approved", type: "bool", }, ], name: "ApprovalForAll", type: "event", }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "_fromTokenId", type: "uint256", }, { indexed: false, internalType: "uint256", name: "_toTokenId", type: "uint256", }, ], name: "BatchMetadataUpdate", type: "event", }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "_tokenId", type: "uint256", }, ], name: "MetadataUpdate", type: "event", }, { anonymous: false, inputs: [ { indexed: false, internalType: "uint256", name: "", type: "uint256", }, ], name: "NFTMinted", type: "event", }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "from", type: "address", }, { indexed: true, internalType: "address", name: "to", type: "address", }, { indexed: true, internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "Transfer", type: "event", }, { inputs: [ { internalType: "address", name: "to", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "approve", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "address", name: "owner", type: "address", }, ], name: "balanceOf", outputs: [ { internalType: "uint256", name: "", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "getApproved", outputs: [ { internalType: "address", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "getToken", outputs: [ { internalType: "uint256", name: "", type: "uint256", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "owner", type: "address", }, { internalType: "address", name: "operator", type: "address", }, ], name: "isApprovedForAll", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "mint", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [], name: "name", outputs: [ { internalType: "string", name: "", type: "string", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "ownerOf", outputs: [ { internalType: "address", name: "", type: "address", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "from", type: "address", }, { internalType: "address", name: "to", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "safeTransferFrom", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "address", name: "from", type: "address", }, { internalType: "address", name: "to", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, { internalType: "bytes", name: "data", type: "bytes", }, ], name: "safeTransferFrom", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "address", name: "operator", type: "address", }, { internalType: "bool", name: "approved", type: "bool", }, ], name: "setApprovalForAll", outputs: [], stateMutability: "nonpayable", type: "function", }, { inputs: [ { internalType: "bytes4", name: "interfaceId", type: "bytes4", }, ], name: "supportsInterface", outputs: [ { internalType: "bool", name: "", type: "bool", }, ], stateMutability: "view", type: "function", }, { inputs: [], name: "symbol", outputs: [ { internalType: "string", name: "", type: "string", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "tokenURI", outputs: [ { internalType: "string", name: "", type: "string", }, ], stateMutability: "view", type: "function", }, { inputs: [ { internalType: "address", name: "from", type: "address", }, { internalType: "address", name: "to", type: "address", }, { internalType: "uint256", name: "tokenId", type: "uint256", }, ], name: "transferFrom", outputs: [], stateMutability: "nonpayable", type: "function", }, ]; State.init({ general: { chainId: undefined, balance: 0, }, theme: undefined, store: { stores: [], storeName: "", storeAddress: "", storeNames: [], isStore: false, storePendingTransactions: [], }, user: { userPendingTransactions: [], }, }); const cssFont = fetch( "https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800;900&display=swap" ).body; const Root = styled.div` width: 100%; display: flex; font-family: Poppins, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; ${cssFont} flex-direction: column; padding: 0; align-items: center; justify-content: center; box-sizing: border-box; `; const WalleyTitle = styled.h1` text-align: center; font-weight: 900; width: 100%; margin: 0px; padding: 5px; color: #000; `; const WalleyContainer = styled.div` background: linear-gradient( to bottom, orange 0%, orange 75%, white 75%, white 100% ); ; color: white; width: 100%; padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: space-betweeen; `; const WalleyHomeTop = styled.div` font-weight: 500; font-size: 50px; width: 50%; height: 100%; padding-bottom: 10px; @media screen and (max-width: 600px) { font-size: 30px; font-weight: 700; width: 70%; } `; const WalleyHomeBottom = styled.div` position: relative; top: 50%; height: 200px; background-color: white; border: 1px solid gray; font-weight: 500; width: 100px; text-align: left; `; const sender = Ethers.send("eth_requestAccounts", [])[0]; const updateBalance = (balance) => { State.update({ balance }); }; if (!sender) { return ( <Root> <WalleyContainer> <WalleyTitle>Walley.</WalleyTitle> <WalleyHomeTop>Highly Secured NFT-based Wallet.</WalleyHomeTop> <WalleyHomeBottom> Get Started <Web3Connect connectLabel="Connect Wallet" /> </WalleyHomeBottom> </WalleyContainer> </Root> ); } if (state.chainId === undefined && ethers !== undefined && sender) { Ethers.provider() .getNetwork() .then((chainIdData) => { if (chainIdData?.chainId) { State.update({ chainId: chainIdData.chainId }); } }); Ethers.provider() .getBalance(sender) .then((balance) => { console.log(balance); updateBalance(Big(balance).div(Big(10).pow(18)).toFixed(5)); }); } if (state.chainId !== undefined && state.chainId !== 11155111) { return <p>Switch to Ethereum Sepolia</p>; } // console.log(NFTManagerABI); const nftIface = new ethers.utils.Interface(NFTManagerABI); // console.log("hehe"); const nftContract = new ethers.Contract( nftAddress, NFTManagerABI, Ethers.provider().getSigner() ); const walleyIface = new ethers.utils.Interface(WalleyABI); const walleyContract = new ethers.Contract( walleyAddress, WalleyABI, Ethers.provider().getSigner() );