it might be simple but I am in the process of learning solidity. In remix IDE, debugging a contract function, the function starts with two requires:
function transferFrom(address owner, address buyer, uint numTokens) public override returns (bool) {
require(numTokens <= balances[owner]);
require(numTokens <= allowed[owner][msg.sender]);
balances[owner] = balances[owner].sub(numTokens);
allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens);
balances[buyer] = balances[buyer].add(numTokens);
emit Transfer(owner, buyer, numTokens);
return true;
}
The balance of the owner is OK but the allowed mapping is empty.
The locals are:
{
"owner": {
"value": "0x5B38DA6A701C568545DCFCB03FCB875F56BEDDC4",
"type": "address"
},
"buyer": {
"value": "0xAB8483F64D9C6D1ECF9B849AE677DD3315835CB2",
"type": "address"
},
"numTokens": {
"value": "1",
"type": "uint256"
},
"<1>": {
"value": false,
"type": "bool"
}
}
The state are:
{
"name": {
"length": "0x0",
"raw": "0x",
"type": "string",
"value": "<constant>",
"constant": true,
"immutable": false
},
"symbol": {
"length": "0x0",
"raw": "0x",
"type": "string",
"value": "<constant>",
"constant": true,
"immutable": false
},
"decimals": {
"value": "<constant>",
"type": "uint8",
"constant": true,
"immutable": false
},
"balances": {
"value": {
"0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4": {
"value": "7770999963",
"type": "uint256"
},
"000000000000000000000000ab8483f64d9c6d1ecf9b849ae677dd3315835cb2": {
"value": "1",
"type": "uint256"
},
"0000000000000000000000000000000000000000000000000000000000000000": {
"value": "32",
"type": "uint256"
},
"0000000000000000000000004b20993bc481177ec7e8f571cecae8a9e22c02db": {
"value": "4",
"type": "uint256"
}
},
"type": "mapping(address => uint256)",
"constant": false,
"immutable": false
},
"allowed": {
"value": {},
"type": "mapping(address => mapping(address => uint256))",
"constant": false,
"immutable": false
},
"totalSupply_": {
"value": "7771000000",
"type": "uint256",
"constant": false,
"immutable": false
},
"addressTable": {
"value": {},
"type": "mapping(string => address)",
"constant": false,
"immutable": false
}
}
How can the second require passes and the status in Remix IDE terminal is true Transaction mined and execution succeed?
console.log
, I can log:console.log: allowed[owner][msg.sender] : 100
while still having an empty mapping:"allowed": { "value": {}, "type": "mapping(address => mapping(address => uint256))", "constant": false, "immutable": false }
so I have to conclude you are right. But what a tricking debugging tool! Thank you @Ismael