New answers tagged


You should not adjust the scale like this. msg.value is already scaled properly. tokens = msg.value * 10; This is useless. A balances mapping is usually used to track liabilities owed by the contract to other users. But you forward the funds immediately so you have no need for this. balances[msg.sender] = safeAdd(balances[msg.sender], tokens); It's not ...


You should look into ERC777 standard for your requirements. It defines advanced features to interact with tokens. Namely, operators to send tokens on behalf of another address—contract or regular account—and send/receive hooks to offer token holders more control over their tokens. this might help: ERC777 with ERC20 backward compatibility and ERC777 ...


In general, cannot send ETH to a smart contract that does not have the receive function or a payable function. There are two non-standard ways ways to get ETH into a smart contract: Send ETH to another contract and selfdestruct that contract with the destination address as the address you want to send ETH to. Mine a block and send the ETH reward to the ...


In order for a smart contract to receive Ether from any kind of account, it has to have a payable function, otherwise it won't be able to receive coins.

Top 50 recent answers are included