Estoy usando Ropsten Testnet y Remix.
¿Hay un error obvio en este código? ¿Por qué no acepta eth.
función () público a pagar { comprar (); }
function buy () payable public whenNotPaused beforeDeadline afterStartTime saleNotClosed {
require(msg.value >= minContribution);
// Update the sender's balance of wei contributed and the amount raised
uint amount = msg.value;
uint currentBalance = balanceOf[msg.sender];
balanceOf[msg.sender] = currentBalance.add(amount);
amountRaised = amountRaised.add(amount);
// Compute the number of tokens to be rewarded to the sender
// Note: it's important for this calculation that both wei
// and PDT have the same number of decimal places (18)
uint numTokens = amount.mul(rate);
// Transfer the tokens from the crowdsale supply to the sender
if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
FundTransfer(msg.sender, amount, true);
// Check if the funding goal or cap have been reached
// TODO check impact on gas cost
checkFundingGoal();
checkFundingCap();
}
else {
revert();
}
}
El contrato Crowdsale tiene una asignación. El límite de gas se ha aumentado de muchas maneras. ¡Advertencia de mi monedero ether!
El código completo está aquí: https://ropsten.etherscan.io/address/0x500c3ff2c1a561cd0fda1cf0c77fe0d17af5fda5
¿Qué me estoy perdiendo aquí?. Gracias de antemano por su respuesta. La última pregunta quedó sin respuesta, ¡así que vuelvo a preguntar!
la función de reserva no puede ejecutar su función de compra () ya que solo tiene un estipendio de 2300 de gasolina. check ¿Cuánto cálculo se puede hacer en una función de respaldo?
así que elimínelo de la función de respaldo y llámelo directamente
function () payable public { }
function buy () payable public whenNotPaused beforeDeadline afterStartTime saleNotClosed {
require(msg.value >= minContribution);
// Update the sender's balance of wei contributed and the amount raised
uint amount = msg.value;
uint currentBalance = balanceOf[msg.sender];
balanceOf[msg.sender] = currentBalance.add(amount);
amountRaised = amountRaised.add(amount);
// Compute the number of tokens to be rewarded to the sender
// Note: it's important for this calculation that both wei
// and PDT have the same number of decimal places (18)
uint numTokens = amount.mul(rate);
// Transfer the tokens from the crowdsale supply to the sender
if (tokenReward.transferFrom(tokenReward.owner(), msg.sender, numTokens)) {
FundTransfer(msg.sender, amount, true);
// Check if the funding goal or cap have been reached
// TODO check impact on gas cost
checkFundingGoal();
checkFundingCap();
}
else {
revert();
}
}
La llamada de función que está fallando es una llamada a este método:
function setTokenOffering(address offeringAddr, uint256 amountForSale) external onlyOwner onlyTokenOfferingAddrNotSet {
require(!transferEnabled);
uint256 amount = (amountForSale == 0) ? TokenAllowance : amountForSale;
require(amount <= TokenAllowance);
approve(offeringAddr, amount);
tokenAllowanceAddr = offeringAddr;
}
Ya ha llamado a la enableTransfer
función que se establece transferEnabled
en verdadero. Entonces, la primera línea del método anterior require(!transferEnabled);
fallará y la ejecución se detendrá.
Roberto
Roberto
Badr Bellaj
Roberto