What should happen when I modify an array, afterwards in the same execution the function fails?
Should I expect the pushed value to be presented or does it get deleted?
for example:
contract MyToken is ERC721Token("My Token", "MYTKN"), Ownable {
struct TokenInfo {
// ...
}
TokenInfo[] public tokens;
// ...
function mint(string userId) public payable {
uint256 tokenId = tokens.push(newToken) - 1;
string tokenUri = concat(BASE_URI, tokenId);
// >>>>>>>>> Maybe function fails here <<<<<<<<
// ...
_mint(msg.sender, tokenId);
_setTokenURI(tokenId, tokenUri);
// >>>>>>>>> Maybe function fails here <<<<<<<<
}
}
requireorrevertstatement in Solidity. If the failure is because of pretty much anything else, it'll eat all available gas. – natewelch_ Jul 21 '18 at 16:05