Skip to content

Instantly share code, notes, and snippets.

View RareSkills's full-sized avatar

RareSkills RareSkills

View GitHub Profile
interface IExampleInterface {
	event Deposit(address indexed sender, uint256 amount);
}

contract ExampleContract is IExampleInterface {
	function deposit() external payable {
		emit Deposit(msg.sender, msg.value);
	}
}
contract ParentContract {
  event NewNumber(uint256 number);

  function doSomething(uint256 number) public {
    emit NewNumber(number);
  }
}

contract ChildContract is ParentContract {
pragma solidity ^0.8.15;
contract ExampleContract {

    event SomeEvent(uint256 blocknum, uint256 indexed timestamp);

    function selector() external pure returns (bool) {

        // true
 return SomeEvent.selector == keccak256("SomeEvent(uint256,uint256)");
```solidity
pragma solidity ^0.8.15;
contract ExampleContract {
event SomeEvent(uint256 blocknum, uint256 indexed timestamp);
function selector() external pure returns (bool) {
// true
return SomeEvent.selector == keccak256("SomeEvent(uint256,uint256)");
pragma solidity ^0.8.15;
contract ExampleContract {

    event SomeEvent(uint256 blocknum, uint256 timestamp) anonymous;

    function selector() public pure returns (bool) {

        // ERROR: does not compile, anonymous events don't have selectors
 return SomeEvent.selector == keccak256("SomeEvent(uint256,uint256)");
op code Usage
log0(p, s) log without topics and data mem[p…(p+s))
log1(p, s, t1) log with topic t1 and data mem[p…(p+s))
log2(p, s, t1, t2) log with topics t1, t2 and data mem[p…(p+s))
log3(p, s, t1, t2, t3) log with topics t1, t2, t3 and data mem[p…(p+s))
log4(p, s, t1, t2, t3, t4) log with topics t1, t2, t3, t4 and data mem[p…(p+s))
const ethers = require('ethers');
const tokenAddress = '0x...';
const filterAddress = '0x...';
const tokenAbi = [
// ...
];
const { ethers } = require("ethers");
// const provider = your provider
const abi = [
"event Transfer(address indexed from, address indexed to, uint256 value)"
];
const tokenAddress = "0x...";
const contract = new ethers.Contract(tokenAddress, abi, provider);
contract ExampleContract {

  // We will explain the significance of the indexed parameter later.
  event ExampleEvent(address indexed sender, uint256 someValue);

  function exampleFunction(uint256 someValue) public {
    emit ExampleEvent(sender, someValue);
  }
}
import { ethers } from "hardhat";
async function main() {
const [user] = await ethers.getSigners();
const data = "0x5197c7aa"; // function selector for the `getX` function
const Slot = await ethers.getContractFactory("Wrong");
const slot = await Slot.deploy();
await slot.deployed();