This is my first time working with Solidity and I soon ran into an issue.
When an address doesn't have enough balance or doesn't have the authority to add coins I want to log an error, when these exceptions happen the script does what it's supposed to do which is return
. The issue is that I can't seem to find my logs anywhere.
This is the code:
pragma solidity ^0.4.0;
contract Testcoin {
address public creator;
mapping (address => uint) public balances;
event Delivered(address from, address to, uint amount);
event StringLogger(string message);
function TestCoin() {
creator = msg.sender;
}
function create(address receiver, uint amount) {
if (msg.sender != creator){
emit StringLogger('This Account is not allowed too create tokens.');
revert();
}
balances[receiver] += amount;
}
function transfer(address receiver, uint amount) {
if (balances[msg.sender] < amount){
emit StringLogger('Not enough balance');
revert();
}
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Delivered(msg.sender, receiver, amount);
}
}
When for example the sender has 3000 balance and tries to send 4000 to x address I receive a log that the transaction was mined but failed but the output and logs are empty.
How could I get to see the logs so I can see exactly what happened?