Una dirección envía eth a mi contrato Y le pagaré a A otro token
ese es mi código de función, pero no funciona. ¿Dónde me equivoco?
pragma solidity ^0.4.16;
contract ICOProxy {
address tokenaddr;
function () payable public{
uint256 amount = msg.value* 10 ;
address se=msg.sender;
bytes4 methodId =bytes4(keccak256("transferFrom(address,address,uint256)"));
tokenaddr.call(methodId,owner,se, amount);
}
}
Si agrega la interfaz correcta, no hay necesidad de intentar construir manualmente los datos de la llamada. Algo como esto debería funcionar:
pragma solidity ^0.4.19;
contract ERC20 {
function transferFrom(address, address, uint256);
}
contract ICOProxy {
address tokenaddr; // initialize this somewhere
address owner; // initialize this somewhere
function () payable public{
uint256 amount = msg.value * 10;
// Use require(...) here to revert the transaction of the transfer fails.
// The owner will need to call approve() to allow this call to work.
require(ERC20(tokenaddr).transferFrom(owner, msg.sender, amount));
}
}
ogro leo
ogro leo
usuario19510
ogro leo
usuario19510
ogro leo
usuario19510
ogro leo
ogro leo
usuario19510
usuario19510
approve()
.ogro leo