pragma solidity ^0.8.11;
contract Test {
event Deposit(address indexed _from, bytes32 indexed _id, uint _value);
function deposit(bytes32 _id) public payable {
emit Deposit(msg.sender, _id, msg.value);
}
}
var abi = /* abi as generated using compiler */;
// 要使用合約內容必須要得到合約在 compiler 之後輸出的 abi
var ClientReceipt = web3.eth.contract(abi);
var clientReceiptContract = ClientReceipt.at("0x1234...ab67" /* address */);
// 呼叫事件 Deposit:
var event = clientReceiptContract.Deposit(function(error, result) {
if (!error)console.log(result);
});
{
"returnValues": {
"_from": "0x1111...FFFFCCCC",
"_id": "0x50...sd5adb20",
"_value": "0x420042"
},
"raw": {
"data": "0x7f...91385",
"topics": ["0xfd4...b4ead7", "0x7f...1a91385"]
}
}
logs =
[
{
"from": "0x9DD41ECd6e1701CE34523ed98423c1eFb0805aBD",
"topic": "0x19dacbf83c5de6658e14cbf7bcae5c15eca2eedecf1c66fbca928e4d351bea0f",
"event": "Deposit",
"args": {
"0": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4",
"1": "0x05416460deb76d57af601be17e777b93592d8d4d4a4096c57876a91c84f4a712",
"2": "0",
"_from": "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4",
"_id": "0x05416460deb76d57af601be17e777b93592d8d4d4a4096c57876a91c84f4a712",
"_value": "0"
}
}
]