5

actually in solidity docs it's pointing that for each public member variable there will be a getter is defined automatically. In short you'll be able to get basic type public member like this: let x = await contract.totalAllocPoint(); you've been missing parenthesis here. While you can get array like: let y = await contract.poolInfo(2); if the array length ...


4

The following line in your contract is triggering the error. uint x = IERC20(0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa).balanceOf(address(this)); Looking at your hardhat config, you using a fresh local development network where 0x4F96Fe3b7A6Cf9725f59d353F723c1bDb64CA6Aa is likely an empty account, since I couldn't see any other logic that deploys an ERC20 ...


3

The API for doing this is defined in EIP-747. You'll need to use the wallet_watchAsset method, something along the lines of the following example code: const tokenAddress = '0xd00981105e61274c8a5cd5a88fe7e037d935b513'; const tokenSymbol = 'TUT'; const tokenDecimals = 18; const tokenImage = 'http://placekitten.com/200/300'; try { // wasAdded is a boolean. ...


2

You don't use payable for non-protocol type of transfer. ERC20 isn't "protocol" because it is defined in a contract. There is no way to detect ERC20 tokens that are blindly transferred to a contract. At best, the contract can check it's balance but it won't know who sent money, so this is no good. uint myTokenBalance = IERC20(<tokenAddress>)....


2

A Launch App button often appears on the top-right corner of Ethereum-platform websites. Is this an indication that a link is a link to a DApp (decentralized application)? Not necessarily. The button is usually just a link to a sub-page or page on a sub domain, regardless of what's at the destination. Are the following two websites DApps? They are. What ...


2

What I can say from my experience, is that none of the above replies worked out of the box for me. This is how I have implemented it (tested with MetaMask and WalletConnect) Frontend web App (ReactApp) Challenge is to sign a nonce (random string) provided by server. This is how a safe sign can be required let sign = await web3.eth.personal.sign(nonce, ...


2

You need both. You use Solidity for the contract, or Vyper less commonly. You also usually need front-end and possibly server interactions. Those are usually but not necessarily JavaScript. Hope it helps.


2

To start with, sometimes a separate provider is not needed at all. If you expect users to have a browser wallet (such as Metamask), that wallet has its own connection already, and you can simply utilize that for at least reading blockchain data. If you don't expect (all) users to have (or enable) a browser wallet and/or wish to use a separate background ...


2

Another good tutorial that walks you through the process from start to finish is Alchemy's NFT Minter Tutorial. It's especially focused on walking you through the front end development, including connecting to MetaMask and interacting with on-chain contracts. Starting there lets you wrap your head around how dapps are structured without having to dive into ...


1

From Etherscan API docs: Every block explorer built by Etherscan ( eg. BscScan, PolygonScan, HecoInfo ) requires a different account to be created and hence a different set of API keys Apparently you'll need to create a new API key for BSC. A good tip to keep in mind would be to always leverage the search function in any docs website. Update: The issue is ...


1

Yes, it's possible to have several instances of web3 inside your dApp, but it only makes sense if you want to sign transactions or read data on multiple chains. I don't see any reason why you would want to include multiple providers which are pointing to the same chain.


1

Please see Ethereum Nodes for available options. https://ethereumnodes.com/ Multiple options might be cheaper than Infura. For example, CloudFlare is free. However they offer limited history and might be slower. You can also run your own node for ~$75/month.


1

You could do the following: const ethers = require('ethers'); const genericErc20Abi = require(..../.../Erc20.json); const tokenContractAddress = '0x...'; const provider = ...; (use ethers.providers.InfuraProvider for a Node app or ethers.providers.Web3Provider(window.ethereum/window.web3) for a React app) const contract = new ethers.Contract(...


1

Something like this might work function transfer(address recipient, uint256 amount) public { // Fee 1% uint256 fee = amount / 100; require(_balances[msg.sender] >= amount); // Credit 99% to recipient _balances[recipient] += (amount - fees); // Remove 100% from sender _balances[msg.sender] -= amount; // Burn fee ...


1

If you want to be a "full stack" Ethereum developer, and you cannot rely on the help of other team members, this is the body of knowledge you need to minimally know Front-end JavaScript to write user interfaces and interact with MetaMask HTML, a necessary frontend basic skill CSS, a necessary frontend basic skill Modern JavaScript frameworks ...


1

It means, the interface is trying to call a contract that doesn't exist.


1

Ethereum doesn't do that. You need a price source which could be on-chain or off-chain. Off-chain would be an exchange or other service, e.g CoinMarketCap and that would be an API. On-chain could be a price Oracle or liquidity pool, e.g. ChainLink or Uniswap. There are many in both cases. Hope it helps.


1

I solved this problem by creating a new child smart contract and deploying a new instance (with a new address) for each user upon his first access to the parent contract: contract userWallet is IERC20 { ... } then in the parent contract: _userWallet[_msgSender()] = address(new userWallet(...));


1

There's not fixed rule, but usually part of a dapp may work on-chain and part off-chain. While a static frontend with some js can satisfy the former, the latter may require additional resources (e.g. bandwith, database, mail services, ...). ...btw many projects are still hosting on cheap VPS instead of the cloud ;)


1

If your concern is about security, a general approach is by using package dotenv in order to load environment variables and avoid hardcoding secret keys or mnemonics in your code. You just need to create a file like this in your root directory: .env In this file you can add all the passwords you need, for instance: INFURA_APP_KEY=xxxxxxxxxxx Finally, you ...


1

MetaMask will no longer be injecting web3, so it's not good practice to rely on it. I used the ethers.js library. I had to pull that in to my project using rollup.js, but you could also use bundler or webpack or whatever. const { ethereum } = window; if (ethereum) { var provider = new ethers.providers.Web3Provider(ethereum); } ... const ...


1

As answered by Alexey, the error happens because of undefined defaultAccount property. The work around for it in javascript is adding the below statement web3.eth.defaultAccount = ethereum._state.accounts[0] Here we have used ethereum._state.accounts[0] instead of web3.eth.accounts[0] since it is deprecated to be used by metamask as documented in the ...


1

I had the same issue for that tutorial looks like once the test is ran it adds an import for react-bootstrap/lib/Breadcrumb. I just removed the import and reran the test and it worked.


1

When I as a user make a transaction, where or what node(s) does it get sent to first? The nodes your node knows about - its connected peers. This will be a subset of the entire network. (Explained in more detail later.) How does an Ethereum node, in terms of implementation details, determine that? Ethereum uses its own set of networking and peer-discovery ...


1

What is "swap" presicely between ERC20 tokens? Is it exchanging one ERC20 token for the other without fees, A "swap" is a trade, which may or may not include an explicit fee. By "trade" I mean you are buying one currency or token for another. As we're talking about ERC20 tokens, and not derivatives*, the term "swap" ...


1

Your best bet may be to use Noah Zinsmeister's web3-react. It is fully customizable and will let you achieve all of your goals. Another alternative is Blocknative's Onboard achieves what you want. Their interface is relatively customizable. Integration is very similar to that of the options you have tried so far.


1

You can use the eth_accounts JSON-RPC call which returns the list of accounts owned by the client. Metamask API implements it with : const accounts = await ethereum.request({ method: 'eth_accounts' }); const currentAccount = accounts[0]; The first item of the list should return the current used account. Then just compare the returned value with the ...


1

I'm not convinced that spawning new instances is the ideal way to keep it simple. It will certainly make it more expensive to start an instance of crowdfunding which could be detrimental when gas prices are high. A singleton doesn't have to be complex. You can consider separating concerns with a library that defines a Type, Crowdsale and primitive functions. ...


1

Here you can find telegram chat https://t.me/dev_solidity


Only top voted, non community-wiki answers of a minimum length are eligible