Hot answers tagged

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 ...


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)....


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

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 / ...


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.


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