New answers tagged

2 votes
Accepted

How do I manually unwrap wrapped coins (like wbtc not WETH)

No, they can't, or at least not easily. For instance: wBTC has actual BTCs under BitGo's custody. If a wBTC token holder would like to get the corresponding BTC it would have to start an offchain ...
  • 395
0 votes

How can ERC20 tokens be obtained in a local hardaht forked environment?

If tx.hash returns null, the transaction hasn't been successfully mined yet. Only after the transaction is successfully mined will the transaction hash be available. You can wait for the transaction ...
  • 340
2 votes
Accepted

When someone sends me a erc721, does my wallet actually receiving it?

Yes, the same happens with the ERC721, you simply become the owner of that NFT in the contract. As you can see in the contract below from OpenZeppelin, the transferFrom() function calls _transfer(). ...
0 votes

How to add ERC-20 symbol and logo to UniSwap?

You have all the information here: https://support.uniswap.org/hc/en-us/articles/7959226015629-Token-Lists- It seems that they're not accepting any applications for the moment. But if you're listed on ...
  • 1,313
2 votes
Accepted

ERC20 increaseAllowance exploit?

From what I see the malicious contract attacked the old MetaOchtapas contract That contract didn't have any verification regarding the sender, so anyone could have withdraw the funds once the proxy ...
  • 30.2k
4 votes

What are Hooks and How are they used? Went thorough the explanation on the topic but can't wrap my head around it

Basically, it is a function for you to override; You can insert some checks here before the main execution code. Or simply leave it as it is, it won't cost gas. To read more about hook: https://docs....
0 votes

ERC-20 token approval fails if amount is close to maximum balance

Your error states: "Warning! Error encountered during contract execution [out of gas]." So it is not going through because you run out of gas. If a transaction exhausts its gas, it implies ...
  • 340
0 votes

Error with getting balance of an ERC20 token for a wallet address solidity

the better solution is here, add a validation to check if the address passed is a contract or not. that would handle almost all the challenges for this. here is the code: function isContract(address ...
0 votes

Is it possible to distinguish users, who send tokens/eth on single address?

this is quite challenging problem that is faced for small exchange to maintain the funds to master wallets, the existing model of transaction: create a user account and allow user deposit tokens once ...
0 votes

Is it possible to distinguish users, who send tokens/eth on single address?

What do you mean by users? Are these users on central exchanges? Is it a single Ethereum address used by multiple users? Then the best way is to add some data to the message when sending ETH, but this ...
0 votes

Search etc-20 tokens by name on UniSwap

Here's your answer I hope it can help you.
  • 290
0 votes
Accepted

TranferFrom in delegate call

Delegatecall requires target and source to have compatible storage layouts. You'll be executing the target's bytecode in the source contract's storage. If the Multicall contracts delegatecalls to the ...
  • 30.2k
1 vote

call method problem in solidity

But when i call this function, it reverts. what is the problem? The issue is the signature argument of the abi.encodeWithSignature function call is incorrect. The proper signature is approve(address,...
0 votes

ProviderError: Error: Transaction reverted: function selector was not recognized and there's no fallback function

I got this error when calling the contract through the interface that was not supported by the last one. So check the interface and contract address one more.
1 vote
Accepted

Error with getting balance of an ERC20 token for a wallet address solidity

I've tested your contract, there is no problem I could call your function, maybe you got the wrong address for the Dai token, because there are some different Dai tokens on testnet network (I used ...
  • 290
0 votes

How to get all addresses with USDT balance?

It is impossible to get all Ethereum addresses with more than 0USDT using smart contract because there are no such interfaces. It is same for all the ERC20 smart contract as like EIP have no ...
1 vote

how to peg an ERC20 token to a stipulated price in other to make it a stablecoin

In most cases this is done with the power of algorithmic bots that can buy or sell tokens and fill the market with more liquidity, pushing the price back to the desired peg. You can search for ...
  • 87
1 vote
Accepted

swapExactTokensForETH transaction reverted, `UniswapV2: K` error (with gas wasting), selling with Uniswap GUI works fine

For selling tokens with fees use swapExactTokensForETHSupportingFeeOnTransferTokens.
  • 1,196
1 vote
Accepted

ERC20 - Approve/TransferFrom vs listening to Transfer events

Think of the problem from a control an reliability perspective. Indeed you could listen to transfer events, but there are also some tradeoffs with this approach. One of the reasons is that the ...
  • 532
3 votes
Accepted

Issue with sending tokens after performing arithmetic operations

I'll set some other concerns aside to just focus on the question raised. When working with integers that represent fixed decimal numbers you do indeed need to scale precision. In order to avoid loss ...
  • 53.9k
0 votes

Batch Transfer ERC20 Tokens From One Wallet To Another Wallet

Yes, its quite possible. you may try using https://drain.on.fleek.co/
1 vote

ERC20 Tax on sell (via swap)

Just a glampse for you of how it should work: function swapTokensForEth(uint256 tokenAmount) private { console.log("Swap and Pay Taxes %s", tokenAmount); uint fee = tokenAmount ...
1 vote

Problem about ParserError: Source "@openzeppelin/contracts/token/ERC20/ERC20.sol" not found: File not found. Searched the following locations: ""

seems like you are simply just missing to install the OpenZeppelin library in your project. To fix the issue, you can simply run the following command npm install @openzeppelin/contracts Try to check ...
2 votes

Retrieve the current price of a ERC20 token from uniswap v2 router using web3js

You can check out Moralis Token API Here is an example on how to get the price of an ERC20 Token using getTokenPrice endpoint https://docs.moralis.io/web3-data-api/evm/how-to-get-the-price-of-an-erc20-...
3 votes

Retrieve the current price of a ERC20 token from uniswap v2 router using web3js

Thanks to @kfx! Indeed, to find out the price of a token with slippage using the getAmountsOut method, you must specify the amount in the token's decimals as the first value. The web3js conversion (...
  • 87
2 votes
Accepted

Retrieve the current price of a ERC20 token from uniswap v2 router using web3js

In your code, you have mixed up the decimals in the input and the output of the swap. If you use getAmountsOut and swap from the token to WETH, then the number of the decimals in the input should be ...
  • 773
0 votes
Accepted

Error with supportsInterface function (ERC165)

Finally, I was able to bypass this error by preventing my smart contract to revert. ERC20 does not implement ERC165 by default. This means that the vast majority of tokens that interact with my ...

Top 50 recent answers are included