I've gone through with the debugger to make sure msg.sender is my metamask account and that it should be updating.
I'm messing with the 0xBitcoin ERC20 contract.
function myfunction() {
balances[msg.sender] = balances[msg.sender].add(reward_amount)
// My contract is 18 decimals but even after converting the amount to "ether"-like
// units the amount is still 2 digits long. So it's not that the update is too small
emit Mint(msg.sender, reward_amount, epochCount, challengeNumber
}
Where Mint is defined as
event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber);
So in summary my account balance doesn't update and I've checked
1) message.sender value
2) reward_amount is large enough that it should be visible
3) the transaction is going to completion without any errors preventing it
What could be going wrong that I haven't considered?
Here's the entire function. It's basically straight from the 0xBitcoin contract cited above.
function Mint(uint256 nonce, bytes32 challenge_digest) public returns (bool success) {
bytes32 digest = keccak256(abi.encodePacked(challengeNumber, msg.sender, nonce));
if (digest != challenge_digest) revert();
if(uint256(digest) > miningTarget) revert();
bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); // same answer can't be awarded twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances[msg.sender].add(reward_amount);
tokensMinted = tokensMinted.add(reward_amount);
lastRewardTo = msg.sender;
lastRewardAmount = reward_amount;
lastRewardEthBlockNumber = block.number;
_startNewMiningEpoch();
emit Mint(msg.sender, reward_amount, epochCount, challengeNumber);
return true;
}
myfunction
? How are you executing this function? Please share the relevant web3 code.