Cuando estoy probando el withdraw()
método de "WithdrawalContract" de http://solidity.readthedocs.io/en/develop/common-patterns.html usando Remix y testrpc, reportó el siguiente error. El límite de gas Testrpc está establecido en 0xffffff. ¿Alguna pista sobre por qué aparece este problema?
callback contain no result Error: Error: base fee exceeds gas limit
at runCall (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:88096:17)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11855:24
at replenish (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8948:17)
at iterateeCallback (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8933:17)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:8908:16
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:11860:13
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74400:16
at replenish (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74347:25)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74356:9
at eachLimit (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74280:36)
at /home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:75460:16
at VM.AsyncEventEmitter.emit (/home/chankh/anaconda3/lib/node_modules/ethereumjs-testrpc/build/cli.node.js:74051:3)
FYI El código del contrato es
pragma solidity ^0.4.11;
contract WithdrawalContract {
address public richest;
uint public mostSent;
mapping (address => uint) pendingWithdrawals;
function WithdrawalContract() payable {
richest = msg.sender;
mostSent = msg.value;
}
function becomeRichest() payable returns (bool) {
if (msg.value > mostSent) {
pendingWithdrawals[richest] += msg.value;
richest = msg.sender;
mostSent = msg.value;
return true;
} else {
return false;
}
}
function withdraw() {
uint amount = pendingWithdrawals[msg.sender];
// Remember to zero the pending refund before
// sending to prevent re-entrancy attacks
pendingWithdrawals[msg.sender] = 0;
msg.sender.transfer(amount);
}
}
Sugiero probar su contrato usando MyEtherWallet. La configuración es bastante simple:
Ahora puedes interactuar con tu contrato.
En su ejemplo, llamé a la witdraw()
función con límite de gas 30000 y funciona.
ka hei chan