New answers tagged

0

give me 1 eth on my wallet i will give you matic on you erc20 wallet it's all. After all bridge work with smart contract for the security tranfert.


0

You can do with "flashbots"


0

Sometimes, in order to extend a parent contract you will need to override multiple related functions, which leads to code duplication and increased likelihood of bugs. For example, consider implementing safe ERC20 transfers in the style of IERC721Receiver. You may think overriding transfer and transferFrom would be enough, but what about _transfer and _mint? ...


5

The maximum amount of token that a ERC-20 contract can mind (according to the specification) is the max of uint256, which is (2 ** 256)-1 ≈ 10 ** 77. And the decimal variable merely mentions the number of decimal places to be used while displaying the amount on a UI. Theoretically, you could use any decimal. As long as the decimal is less than 77, you'll ...


0

This is how to do it with ethers.js. I don't know why most of the other answers are using an import of an unspecified ABI json when ERC20 follows the same interface for any token, and you're unlikely to have the ABI of a public token. Note in this example I'm assuming the amount needs to be multiplied by a power of 6 (utils.parseUnits(n, 6)) which applies to ...


3

If we look at the ERC20 implementation, the supply is defined as an uint256. uint256 private _totalSupply; In theory the maximum supply a token could reach is 2^256-1. Going over this would cause an overflow which is prevented by solidity 0.8 (will revert by default if not treated as unchecked). The decimals matter only when interpreting what this number is....


1

Within the context of smart contracts, token amounts are always denoted in integers. So, in your case, 196880000 tokens were transferred. What makes this concept a bit tricky is the UIs which make the amount "more user friendly". In your case, the user friendly amount is 196.8. I've earlier invented the terms absolute amount and display amount to ...


0

I guess this would depend on depends why you have made the _mint function external? Perhaps you could consider creating a safe public 'mint' function in the smart contract which calls this and make it internal.


0

Include this line at the beginning of your ERC20 transfer function: require (to != address(this));


0

The contract you try to query (0x1800b081333A08bc5faAbb19a51dfCa15C1dfF21) was compiled with ABIEncoderV2, so maybe etherjs has some problem working with ABIV1 used to call ABIV2 compiled contracts. The definition for decimals is slightly different with V2, but also with other fields so this does not explain why you have the error on decimals only, but just ...


0

In general name, symbol and decimal are optional methods according to EIP-20, therefore you should be prepared to handle that these methods error or return invalid data. There are also contracts that implement this differently (e.g. by returning bytes32 or triggering their fallback method), so if you want to be bulletproof you should add some checks to these ...


1

Burning a token means removing it from circulation, which reduces the number of coins in use. This mechanism is used to bootstrap a new currency or introduce scarcity, which results in the increased value of the coin. Token burn can be done in two ways: 1- manually send it to an unowned Ethereum address which is called "eater" or "burner"...


0

Possible answer: Instead of checking if the sender == deployer, I opted to check if the recipient == deployer and it is working as intended (seemingly). I assume it is due to how exchanges handle transfers during a swap?


0

There is an inbuilt variable called owner(), that is used for just such a thing. (Because your contract is Ownable.) So your code would look something like this contract token is ERC20, Ownable { using SafeMath for uint256; uint taxPercentage = 9; constructor(uint256 initialSupply) ERC20("token", "tkn") { ...


1

I think you are confusing address(this).balance which will give you the native token balance (ETH, MATIC, BNB...) of the contract, with IERC20(tokenAddress).balanceOf(address(this)) which gives you how many tokens of the ERC20 contract this address has. If your goal is to check how many ERC20 token your contract has, you should implement the second option. ...


3

You need to deploy compatible token contracts on both networks, ideally not ERC-20 but ERC-677, and then set up a two-way bridge on both networks. You should look into ChainSafe's Chain Bridge or POA Network's Token Bridge. I would recommend an AMB with an ERC-677-to-677 module. Make sure the bridge mode is set to AMB_ERC_TO_ERC: BRIDGE_MODE=AMB_ERC_TO_ERC ...


0

As I mentioned in Discord :), the problem is in the IERC20 interface - it mentions approve (and others) as a view function.


1

_totalSupply is internal (see https://github.com/ConsenSys/UniversalToken/blob/master/contracts/ERC1400.sol#L49), so you can access it in a contract that extends the ERC1400 implementation. The contract has a method isIssuable which return the state of _isIssuable. If that is set to false (either in a custom constructor or by calling renounceIssuance) not ...


1

Here is the general model. Note that it is possible for some of the entities to be combined. The staking sponsor might be built into the ERC-20 token contract The staking sponsor might be built into the ERC-721 token contract The staking contract might be have its own tokens (no need for sponsor) The ERC-721 might contain the staking contract and also be ...


0

You are trying to change a 9 decimals token (FEG) into a 18 decimal tokens (WBNB - https://bscscan.com/token/0x11ba25374933cec65f1dc6c4fb6b8f25fc924130). You should be using the parseUnits function with the decimals of the target token.


0

In order to make transactions you need pay fee in BNB coin (not WBNB). In addition, Ethereum token not exist in BinanceSmartChain network, only in Ethereum chain. Provide more info about what exactly tokens you wanna swap.


1

So there seem to be a couple of problems with your code. First of all, you pass 0 into Transfer() as an address but an address needs to be a 20 byte value in the form of 0x..... see here. Secondly, as already pointed out in the comments, you are possibly missing the import statements for the contracts you want to inherit from (contract Token is ERC20Token, ...


1

If you take a look at binance docs, they use the exact same functions as ERC-20 openzeppelin packages do (https://docs.binance.org/smart-chain/developer/issue-BEP20.html). Also, almost all tutorials use openzeppelin erc-20 packages to issue BEP-20. Thus the only difference between erc-20 and ‘bep-20’ are the chains the smart contract is hosted on. You can ...


1

As you can see by the keyword virtual these getters can be overridden in the derived contracts. Someone who might want to change the way those getters behave could use this property to do just that. Another thing for me is just simplifying naming. By convention underscore before the name of the variable notes that it is a global variable (state variable in ...


0

I just completed my transfer function and test passed. //Throw if caller doesn't have funds //Trigger transfer Event //return boolean function transfer(address _to, uint256 _value) public returns (bool success) { require(balanceOf[msg.sender] >= _value); balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; return true; } Test ...


1

This completely depends on how you want to distribute your token. Often this is separated between different components. E.g. you deploy your token and mint the initial supply to and distributor address. This distributor could be a contract that is used for an ICO, by selling the token for a specific price. Another way would be to use a MultiSig wallet, such ...


0

USDC uses 6 decimal places and it works perfectly fine.


2

Yes, it will work just fine. It's just typical to have 18 decimals, but nothing really stops you from using a different number. The decimals are only used for external integrations, so the only things that may break are external integrations. But also those should read the amount of decimals from the contract and not assume 18.


0

At the moment bridging of Aurora native tokens to Ethereum is not possible, but eventually this functionality is to be added. However, being ERC-20, the token should originate from Ethereum and then be represented on Aurora. To add it to Aurora, you’ll need to deploy it and create a PR in https://github.com/aurora-is-near/bridge-assets.


0

It is possible to map custom smart contracts to Ethereum. Any Ethereum ERC-20 can be bridged to Aurora, there are no restrictions. However, deploying your own custom token smart contracts on Aurora and mapping it to a token on Ethereum cannot be done directly with the recent update. Aurora bridge works the following way: if a user wants to bridge the token ...


0

The UniswapV2Pair.sol fails in the mint method, called by the contract UniswapV2Router02.sol during the addLiquidityETH/addLiquidity method. The problem is that the pair requires a small amount of balance of both tokens, such that a minimum amount of liquidity can be added. In short, just transfer more than 1000 wei of each token to the pair address and ...


0

There are some tokens that allow us to pay by generating signature off-chain and execute it on-chain such as DAI. Please refer this blog how we can do this with DAI stablecoin. But I don't think we can do the same with USDT as USDT does not support such permit function in its smart contract.


0

there are several solutions to your issues. Gas fees For this one there is a pretty easy option, if you want to keep it as an ERC20 token you could deploy it on a chain like polygon whos fees are significantly smaller than ETH, you could deploy it on BSC but you would have to make it a BEP20 token (the programmatic implementation are practically the same). ...


0

Unfortunately, at the moment there isn't a simple function in Web3 that returns all ERC20 tokens from an address. The simplest solution with Web3 is to loop through all ERC20 token contracts and call the balanceOf function of the smart contracts. Simpler is by using an API that returns all tokens an address owns. The ethplorer.io API does this and is free to ...


0

If you interact with a contract, then the contract address will be in the to section of the hash data. To retrieve Holders information, see here API to gather list of top token holders


1

Just if uses a proxy pattern (upgradable contract). The majority of ERC-20 tokens aren't upgradable, but I've seen stable coins contracts and game tokens contracts using upgradable ERC-20. For instance, USDC uses proxy pattern: https://etherscan.io/token/0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48#readContract a good explanation about upgradable smart-...


Top 50 recent answers are included