New answers tagged

1

You are asking two questions really: What can be stored on-chain What can be stored economically Let's address them separately. What can be stored on-chain? The ERC-721 Metadata Extension (ERC721Metadata) and ERC-1155 Metadata Extension (ERC1155Metadata_URI) both specify that a URI can be attached to an NFT but the specifications are slightly different: ...


0

I've been using such a method and it's safe and also saves some gas. Just why don't you use the transfer() method instead of all that logic? function sendMultiple(address[] memory _redemptions, uint[] memory _values) public returns (bool) { require(_redemptions.length == _values.length); uint256 length = _redemptions.length; for (uint i = 0; ...


1

One way you could achieve that is by: Creating a whitelist of addresses that will be the only ones to transfer your local currency Overriding transfer() to restrict transfers from/to users within the whitelist. In any case, you need an external procedure (off-chain) to determine which users belong to your region, or in other words, you need a centralised ...


0

Since buy is expecting ethers you should send it in the same transaction. it("buy tokens", async () => { let instance = this.StudyCoin; const weiAmount = new BN(5000000000000000); let buyTokens = await instance.buy({ from: deployerAccount, value: web3.utils.toWei(0.005, "ether") }); .. });


0

That contract doesn't follow the final ERC20 specification. The declaration for transferFrom doesn't return anything: function transferFrom(address _from, address _to, uint _value) public; The calling contract defines transferFrom returning a bool instead: function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); ...


-3

If you want, we posted an article about DeFi, you check it out whenever you want What is DeFi? Decentralized Finance Explained


0

If you want to sell your token for Tether and you don't want to write a custom contract, you can: Make a Uniswap pair using UniswapV2Factory https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2Factory.sol#L32 Add liquidity: https://uniswap.org/docs/v2/smart-contract-integration/providing-liquidity/ Let users users swap for your token ...


1

One approach could be through events: You can emit an event whenever there is a transfer from/to your token smart contract from/to an external account. Afterwards, you can retrieve all the related events off-chain without any cost Any other alternative on-chain might have significant gas fees.


1

In theory, yes you could by learning the language of Ethereum smart contracts, Solidity. In practice, if you don't already know how to code, you will have a hard time understanding Solidity. It has its own quirks and there is not much documentation available. It would be much easier to learn another language first to learn how to code (I would suggest Ruby ...


1

Calling balanceOf on the depricated contract calls balanceOf on the upgraded contract. This same pattern is used for the other functions as well. // Forward ERC20 methods to upgraded contract if this one is deprecated function balanceOf(address who) public constant returns (uint) { if (deprecated) { return UpgradedStandardToken(upgradedAddress)....


0

I was able to figure this out after much debugging. Turns out that the chainid OPCODE is not working correctly in Ganche (if you use their UI - the fix has been released in the ganache-cli project). The lack of a proper functioning chainid results in the DOMAIN_TYPEHASH being computed incorrectly which prevents ecrecover from generating the correct address ...


1

If the tokens follows the ERC20 standard use functions totalSupply and balanceOf to calculate the relative percentage. function percentage(address token, address user, uint256 scale) public view returns (uint256) { uint256 totalSupply = IERC20(token).totalSuply(); uint256 balance = IERC20(token).balanceOf(user); return balance * scale / ...


0

You need to have enough ETH in your wallet to pay for the transaction. In a normal situation it wouldn't have costed that much to send tokens but since the network usage is high right now, the tx fee is also high. You can check etherscan to see the gas price required for your transaction to go through: https://etherscan.io/gastracker


0

Any chance of an update? I tried to copy this into a .py file and run it in DOS and it gives an error, probably doesn't work with Python 2.7 or whatever


0

Were you able to get it back? Especially with how much AAVE is right now. I sent 20 days ago LEND from my Trezor to an AAVE address in Gemini without knowing that I was supposed to convert it. I'm waiting for Gemini to get back to me but I hope I can get it back. Any suggestions for how I can get it back would be great.


1

The ERC-20 spec says you need to have an accessor function name() and symbol(). However, you can internally store them as bytes32 to save gas. Accessors would to the conversion from bytes32 to string in fly. It would be a clever optimisation, in fact.


2

Yes, definitely working with bytes32 instead of string will bring less transaction costs, because string has dynamic size. I find it similar to arrays in solidity where for example if you work with fixed size array it's always cheaper than working with dynamic size array. If you're interested in more gas costs savings you can check the following article ...


Top 50 recent answers are included