This is my contract:
pragma solidity ^0.4.22;
contract Test {
event Deposit( address indexed from, uint amt );
event Withdrawal( address indexed to, uint amt );
address owner;
constructor() public {
owner = msg.sender;
}
function Withdraw(uint amt) public {
require(msg.sender == owner);
msg.sender.transfer(amt);
emit Withdrawal(msg.sender, amt);
}
function () payable external {
emit Deposit(msg.sender, msg.value);
}
}
I use truffle v4.1.11 and Solidity v0.4.24
I run docker: run -d -p 8545:8545 trufflesuite/ganache-cli:latest -a 10 --debug
I connect with: truffle console
It connects, the contract deploys. And I can send like this:
Test.at('0xd8f24367662cd76f0723271cfd6000ab3d317e40').send(web3.toWei(1,"ether"))
{ tx:
'0x2b438220d8ab4fe3428409f9d6a9bcb9ab800e0a975b216f06dc8654658c2d45',
receipt:
{ transactionHash:
'0x2b438220d8ab4fe3428409f9d6a9bcb9ab800e0a975b216f06dc8654658c2d45',
transactionIndex: 0,
blockHash:
'0xfcdf0b31d4ac77001f1d6c760e2e5759addc184d311756a97b3f4aa3a86dcaa0',
blockNumber: 27,
from: '0xb9cd57a299ebf2eca11435ed890d5de0717f2889',
to: '0xd8f24367662cd76f0723271cfd6000ab3d317e40',
gasUsed: 21040,
cumulativeGasUsed: 21040,
contractAddress: null,
logs: [],
status: '0x1',
logsBloom:
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
v: '0x1b',
r:
'0x6f76b56ff878c10c3dfed4315d071c160bb1572194197b9f974b7d168d7e816c',
s:
'0x23f68bc8533232aa113aeb0f2ba8e6425f2e0783bcbbc9e6cf825342890d0e73' },
logs: [] }
It all works, but you will notice that logs is empty - why was the Deposit event not emitted?