New answers tagged

0

Ok so I have eventually figured it out! Was really simple, I had the wrong network, should have been "rinkeby" and not "homestead". Homestead is the mainnet and I am still in test mode. It's still a little laggy to show the numbers, but does the trick. Maybe this'll help someone in the future!


0

Actually, it is possible to access the ethereum object from the window object from inside a useEffect hook, but your conditional statement is validating as true before ethereum has been injected since there is no web3 property for window which would evaluate to true when ! compared to undefined. Also, you aren't setting ethereum to a component level scoped ...


0

Reading JSON Files is supported directly. In my Nodejs Express App I loaded the contract: // Load Contract var fs = require('fs'); var jsonFile = "abis/abi.json"; var abi = JSON.parse(fs.readFileSync(jsonFile)); // Contract var contract = new web3.eth.Contract(abi, "0x068_your_address");


0

Adding on to @Medici's answer, you can create a modifier for all your functions such that only payed users can call them. pragma solidity ^0.8.0; contract PayedService { mapping (address => bool) public isCustomer; modifier onlyCustomer(){ require(isCustomer[msg.sender]); _; } function becomeCustomer() payable external {...


0

Welcome to the space! In order to require a certain amount is paid, you can use the payable function modifier and add a require statement at the beginning of your the function which executes the service in question that says if require(msg.value == 1 ether). In case this isn't clear I'll give a simple example through a counter function. pragma solidity ^0.8....


0

Connecting to the mainnet fixed the issue for me, seems the error is from mumbai cause the code works fine on both local and mainnet rpc. I know this isnt an optimal solution especially if you just wanna run some test but this is what worked for me and thought I should share.


0

Are you connected in mobile using the WC web3 connector? If you are, then all interactions should be the same, and should open the mobile MM for approval. If you are using this connector - what happens when you issue a mint tx?


0

you want to use InjectedConnector, const MetaMask = new InjectedConnector({ supportedNetworks: [1, 4] }); const connectors = { MetaMask }; Then you want to wrap your app with: <Web3Provider connectors={connectors} libraryName={"ethers.js"} > <YOUR_APP/> </Web3Provider> Then use it with something like this ...


0

I do not believe this is possible. If someone can find your contract address they can call it. You can still store data off chain, though that data would no longer be immutable. If this isn't a problem for your use case, then you can always provide the off chain data to the contract function at a later time.


1

The idea behind the blockchain is that it's permissionless and transparent. Anyone can verify the blockchain state at any point. Etherscan is just one such UI and anyone can create a front-end to read the state (calling view functions). Regarding writing to the blockchain, anyone with a valid signature can call the external/public functions. So whatever you ...


0

There is a modifier onlyOwner/OnlybyOwner that allows only for the ones who deployed the contract to call the function. Additional owners can be added by the original Owner. ( Look at OpenZeppelin here) But you can create a custom one too, to better suit your requirements. ShortAnswer: You can create a modifier that will limit as to who can call a function. ...


0

All data in Ethereum is transparent. I don't think web3 says much about frontend capabilities; it's not so much about frontends, but about blockchains as backend. So the frontend can use whatever privacy means it wants, but whatever data is in Ethereum, that data is transparent and the frontend can't really do much about that "problem". Part of the ...


1

Bulk minting ERC-721 is not costly. Although the implementation you are considering might be suboptimal. In fact, the very first ERC-721 NFT, Su Squares, minted 10,000 tokens in one transaction. The Su Squares smart contract is now open source, permissively licensed and is referenced in the ERC-721 document.


1

Each token in your ERC-1155 collection will have a unique ID. Could you elaborate more on the problem you're facing? Unless you're talking about nesting fungible or semi-fungible tokens as a 2nd-level structure? For example you can have ERC-1155 collection with IDs = 1, 2, 3 and then under each ID you can have 100 fractions which are fungible tokens ...


0

On mobile WalletConnect tries to default to deeplinking instead of QR codes. If everything is properly integrated you will see a screen like this There you can also switch to the QR code.


0

There's the EIP-2981 NFT Royalty Standard. A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal support for royalty payments across all NFT marketplaces and ecosystem participants.


0

Your script establishes a network connection to an Ethereum node running at Infura. This means that you can use the JSON-RPC API to send commands to the node which lets you execute transactions, check balances, etc. web3.py is using that API to let you deploy contracts and interact with them. MetaMask is a browser extension that can also establish a ...


0

This is indeed possible with WalletConnect. There is a Kotlin library available (both for v1 and v2 of WalletConnect). For v1 you can use: https://github.com/WalletConnect/kotlin-walletconnect-lib You need to generate a WallectConnect session with a valid bridge server (e.g. for testing https://bridge.walletconnect.org/): https://github.com/WalletConnect/...


0

Deleting a mapping basically sets all elements of the struct to the default value. That could have been the issue. I made some small changes, by basically adding a bool that indicates if a task still exists. // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract TodoList { uint public taskCount = 0; mapping(uint => Task) ...


-1

So after deploying a few rails apps to heroku -- I realized a better way: A distributed chain where people sign up to host your app, just like heroku does. So miners get paid to host the app. Each app is made available like a torrent in bittorrent seeded by original author and reseeded by others, and this torrent contains the complete image needed to host ...


0

It seems that the problem was brought about by the Trust wallet itself and after upgrading to the latest version (4.9 on android), the issue is now solved and everything works as expected.


0

I deleted the .dapp folder in home directory and ran dapp testnet again and it worked.


0

The problem is that contracts is declared as address[] public contracts; so it will only accept addresses. You could fix it by casting newContract as address function newCookie(string memory _name) public returns(Cookie newContract) { newContract = new Cookie(_name); contracts.push(address(newContract)); return newContract; }


0

Thank you for your response. So, when I've a stable coin address used onchain, I can't use only this address for deposits and withdrawals? like function Deposit() public payable { require(tokenAddress ==0x6b175474e89094c44da98b954eedeac495271d0f); } function Withdraw(uint _amount) public payable { } By the way, I dont want to create my own token,...


0

How can I prevent users to deposit or withdraw ether or other tokens? You cannot prevent a user from sending ether to a smart contract. Ether can be forcibly sent to a smart contract address. (Read more about that here Can i disable direct transactions to smart contract address?) Once the contract is deployed, and even before the contract is deployed ...


Top 50 recent answers are included