"Error: la tarifa base excede el límite de gasolina" al usar el patrón de retiro

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);
    }
}

Respuestas (1)

¿Ha leído este "error de devolución de llamada que no contiene ningún resultado: Error: la tarifa base excede el límite de gas" cuando llama a la función de autodestrucción (usando Remix IDE) ?

Sugiero probar su contrato usando MyEtherWallet. La configuración es bastante simple:

  1. visite https://www.myetherwallet.com/
  2. en la esquina superior derecha, seleccione el menú desplegable y elija "Agregar nodo personalizado"
  3. agregue la dirección IP y el número de puerto donde se ejecuta testrpc (normalmente es http://127.0.0.1:8545 )
  4. vaya a la pestaña de contrato e inserte la dirección del contrato (implementada con Remix) y su interfaz ABI

Ahora puedes interactuar con tu contrato.

En su ejemplo, llamé a la witdraw()función con límite de gas 30000 y funciona.

Sí, funciona a las mil maravillas.