web3 / web3.js

Collection of comprehensive TypeScript libraries for Interaction with the Ethereum JSON RPC API and utility functions.
https://web3js.org/
Other
19.4k stars 4.97k forks source link

web3.eth.Contract.getPastEvents failed with error 'invalid codepoint at offset 2669; unexpected continuation byte' #5742

Open Yurii-Pristay opened 1 year ago

Yurii-Pristay commented 1 year ago

Is there an existing issue for this?

Current Behavior

Hello, I'm trying to get past events using getPastEvents for contract but receive this error.

Error: description: invalid codepoint at offset 2669; unexpected continuation byte (argument="bytes", value=Uint8Array(0x2223205570677261646520476f7665726e616e636520436f6e747261637420746f20436f6d706f756e64277320476f7665726e6f7220427261766f202023232050726576696f75732044697363757373696f6e3a20205b54656d706572617475726520436865636b5d2868747470733a2f2f676f762e756e69737761702e6f72672f742f74656d70657261747572652d636865636b2d757067726164652d676f7665726e616e63652d636f6e74726163742d746f2d676f7665726e6f722d627261766f2f313336313029207c205b536e617073686f745d2868747470733a2f2f736e617073686f742e6f72672f232f756e69737761702f70726f706f73616c2f516d53634e4c65616a694632685168317a3944597154464b47677252684877724869735634796e6d44455177784829205b436f6e73656e73757320436865636b5d2868747470733a2f2f676f762e756e69737761702e6f72672f742f636f6e73656e7375732d636865636b2d757067726164652d676f7665726e616e63652d636f6e74726163742d746f2d676f7665726e6f722d627261766f2f313337303729207c205b536e617073686f745d2868747470733a2f2f736e617073686f742e6f72672f232f756e69737761702f70726f706f73616c2f516d5762677a484a386e4b325444616a364c46364278414d506168793937644d6d626255356b52427731516b5874292020232320544c3b44523a20205570677261646520556e697377617027732063757272656e7420676f7665726e616e636520636f6e74726163742066726f6d20476f7665726e6f7220416c70686120746f20476f7665726e6f7220427261766f20746f20696d70726f766520676f7665726e616e6365207570677261646162696c69747920616e642070726f746f636f6c207361666574792e20205b4f6e2d436861696e2050726f706f73616c5d2829202023232053756d6d61727920616e64204d6f7469766174696f6e3a20202a436f2d7772697474656e2077697468205b47657474792048696c6c5d2868747470733a2f2f747769747465722e636f6d2f67657474795f68696c6c292028404765747479292c205b45646479204c6565205d2868747470733a2f2f747769747465722e636f6d2f796573696d6564647929202840656c6565292c205b5975616e2048616e204c69205d2868747470733a2f2f747769747465722e636f6d2f7975616e5f68616e5f6c69292028407975616e2d68616e2d6c69292c205b4a6f686e2057616e67205d2868747470733a2f2f747769747465722e636f6d2f6a30686e77616e67292028406a6f686e77616e67292c20616e64205b416c69204b68616d62617469205d2868747470733a2f2f747769747465722e636f6d2f616c696b68616d626174693129202840616c696b68616d62617469292a2020476f7665726e6f7220416c7068612c207468652063757272656e7420676f7665726e616e636520636f6e747261637420757365642c2077617320612067726561742073746172742c2062757420696e206c69676874206f6620436f6d706f756e64277320616e64206f746865722070726f746f636f6c73207570677261646520746f20476f7665726e6f7220427261766f2c20556e69737761702073686f756c64206d69677261746520676976656e20427261766f2773206164646974696f6e616c207361666574792062656e656669747320616e64207570677261646162696c6974792e2020312e202a2a4e617469766520757067726164656162696c6974793a2a2a20556e64657220476f7665726e6f7220416c7068612c206368616e67657320746f20676f7665726e616e636520706172616d65746572732072657175697265206465706c6f79696e672061206e657720636f6e747261637420616e6420636f6d706c6574656c79206d6967726174696e6720746f2061206e657720616464726573732e205468697320697320706172746963756c61726c792064616d6167696e6720746f20676f7665726e616e63652070617274696369706174696f6e20617320697420696e74726f647563657320646f776e74696d6520616e64206173796e6368726f6e69636974792e204d616e7920676f7665726e616e636520746f6f6c7320616e6420637573746f6469616e732075736520666163746f727920636f6e74726163747320776869636820706f696e7420746f206120737065636966696320636f6e747261637420616464726573732c206d65616e696e672070617274696573206d757374206d616e75616c6c79207570677261646520746865697220696e6672617374727563747572652065766572792074696d6520676f7665726e616e636520706172616d657465727320617265206368616e67656420756e64657220476f7665726e6f7220416c7068612e205468697320696e636c7564657320746f6f6c7320666f72206372656174696e67206175746f6e6f6d6f75732070726f706f73616c73206c696b65205b666973682e766f7465205d2868747470733a2f2f7777772e666973682e766f74652f293b2066726f6e742d656e64732073756368206173205b54616c6c79205d2868747470733a2f2f7777772e7769746874616c6c792e636f6d2f292c205b537962696c5d2868747470733a2f2f737962696c2e6f72672f232f64656c6567617465732f756e6973776170292c20616e64205b426f617264726f6f6d205d2868747470733a2f2f6170702e626f617264726f6f6d2e696e666f2f292077686963682061676772656761746520616e6420646973706c617920676f7665726e616e636520726573756c747320666f7220766172696f75732070726f746f636f6c733b20616e642070726f66657373696f6e616c20637573746f6469616e73207768696368206172652075736564206279206c6172676520746f6b656e20686f6c646572732c2064656c6567617465732c20616e6420636f6d6d756e697479206d656d626572732e20456e61626c696e6720612073746174696320636f6e747261637420616464726573732074686174206861732070726f7879207570677261646162696c697479207061747465726e7320697320706172616d6f756e7420666f72206d6178696d697a696e672070617274696369706174696f6e2c20616e64206d61696e7461696e696e6720616e206f70656e20616e642073656375726520676f7665726e616e63652070726f636573732e20322e202a2a566f74696e6720726561736f6e20737472696e673a2a2a20476f7665726e6f7220427261766f20676976657320766f7465727320746865206f70706f7274756e69747920746f2061646420667265652d666f726d20636f6d6d656e747320287465787420737472696e67732920616c6f6e672077697468207468656972206f6e2d636861696e20766f7465732e204e6f74206f6e6c7920646f6573207468697320696e63726561736520746865207472616e73706172656e63792061726f756e642074686520726174696f6e616c652070656f706c65206861766520626568696e6420746865697220766f7465732c2062757420697420616c736f20666163696c697461746573206d6f726520696e2d646570746820616e64206e75616e6365642064697363757373696f6e2e20332e202a2a4e6577209880e26162737461696e2720766f74696e67206f7074696f6e3a2a2a20476f7665726e6f7220427261766f20656e61626c657320766f7465727320746f20666f726d616c6c79206162737461696e20726174686572207468616e20666f7263696e67207468656d20746f2063686f6f7365206265747765656e20766f74696e67207965732f6e6f206f72206e6f7420766f74696e6720617420616c6c2e20546869732077696c6c206769766520766f74657273206d6f726520666c65786962696c69747920616e6420616c736f20696e637265617365207472616e73706172656e637920696e746f2064656c6567617465206265686176696f722e20342e202a2a50726f706f73616c206e756d6265727320776f6e27742072657365743a2a2a20556e64657220476f7665726e6f7220416c7068612c20616e7920757067726164657320746f2074686520636f6e747261637420726573657473207468652070726f706f73616c206e756d62657220736368656d612e204e6f746963652074686174205b9880e250726f706f73616c20302e34275d2868747470733a2f2f6170702e756e69737761702e6f72672f232f766f74652f302f34292028776869636820726573756c74656420696e206465706c6f796d656e7420616e64206d6967726174696f6e20746f2061206e657720476f7665726e6f7220416c70686120636f6e74726163742064756520746f206d6f64696679696e67207468652070726f706f73616c207375626d697373696f6e207468726573686f6c6420706172616d6574657229206361757365642074686520666f6c6c6f77696e67206f6e2d636861696e2070726f706f73616c2066726f6d2040486172766172644c617742464920746f206265206e756d6265726564205b9880e250726f706f73616c20312e3127205d2868747470733a2f2f6170702e756e69737761702e6f72672f232f766f74652f312f31292e20556e64657220476f7665726e6f7220427261766f2c207468697320776f756c64206e6f7420626520616e20697373756520616e642070726f706f73616c206e756d6265727320776f756c6420626520636f6e74696e756f757320626563617573652074686520636f6e747261637420776f756c64206265206d61696e7461696e656420617420612073696e676c6520616464726573732e20352e202a2a50726f706f73616c2043616e63656c6c6174696f6e3a2a2a20427261766f20616c6c6f777320757365722d64697265637465642063616e63656c6c6174696f6e7320656e61626c696e67206572726f6e656f75732070726f706f73616c7320746f2062652063616e63656c6564206966206e6565642062652028726174686572207468616e20666f7263696e672070656f706c6520746f20766f7465206e6f2f6162737461696e292e20362e202a2a52657669657720506572696f643a2a2a20476f7665726e6f7220427261766f20616c6c6f777320676f7665726e616e636520746f20696e636c7564652061207265766965772f616e616c7973697320706572696f642e2043757272656e746c792c20436f6d706f756e642075736573206120313331343020626c6f636b20287e322d646179292072657669657720706572696f64207468617420616c6c6f777320686f6c6465727320746f20726576696577207468652070726f706f73616c2e2054686973206d65616e7320746861742075736572732077696c6c206861766520322d6461797320746f207072657061726520666f7220766f74696e672028652e672e2c2072656d6f766520554e492066726f6d2041617665292c20756e6c696b6520476f7665726e6f7220416c70686120776869636820696e7374616e746c7920736e617073686f74732075736572732720766f74696e6720706f7765722e20412072657669657720706572696f64207375627374616e7469616c6c7920696d70726f76657320746865206163636573736962696c69747920616e6420736166657479206f662074686520676f7665726e616e63652070726f636573732e2020232320496d706c656d656e746174696f6e3a20416674657220737065616b696e67207769746820746865204f70656e5a657070656c696e207465616d2061626f7574207468656972207265696d706c656d656e746174696f6e206f6620476f7665726e6f7220427261766f2c207765207468696e6b207573696e6720436f6d706f756e64277320476f7665726e6f7220427261766f20636f6e747261637420696e7374656164206d616b657320746865206d6f73742073656e736520617420746869732073746167652e2020416c74686f756768204f70656e205a657070656c696e277320476f7665726e6f7220636f6e74726163742074616b657320612073696d706c657220617070726f61636820746861742063616e20696e636c75646520616c6c20427261766f2066756e6374696f6e616c6974792c20697420646f6573206e6f7420646f20736f2062792064656661756c742e2054686520636f6e747261637420757365732073696d696c6172206c6f6769632c206275742074686520636f6465206973206e65772e2049742068617320676f6e65207468726f75676820616e20696e7465726e616c20617564697420616e64207265766965772070726f6365737320627574207374696c6c206e6565647320746f20676f207468726f75676820616e2065787465726e616c2061756469742e2020466f72207468652073616665747920616e642073696d706c6963697479206f6620556e69737761702c207765207468696e6b207573696e6720436f6d706f756e64277320476f7665726e6f7220427261766f20636f6e7472616374206973207468652062657374206465636973696f6e20666f72207468652074696d65206265696e672e20436f6d706f756e64277320476f7665726e6f7220636f6e74726163742068617320616c726561647920756e646572676f6e6520616e205b61756469745d2868747470733a2f2f626c6f672e6f70656e7a657070656c696e2e636f6d2f636f6d706f756e642d676f7665726e6f722d627261766f2d61756469742f29206279204f70656e5a657070656c696e20616e6420686173206265656e20776964656c7920757365642e2057652063616e20616c77617973206368616e67652f7570677261646520746f204f70656e205a657070656c696e20476f7665726e6f7220636f6e7472616374206174206120667574757265206461746520696620746865697220636f6e747261637420696e74726f6475636573206e65772066656174757265732f66756e6374696f6e616c6974792074686520636f6d6d756e69747920697320696e746572657374656420696e2e204d6f72652064657461696c73206f6e204f70656e5a657070656c696e277320636f64652063616e20626520666f756e6420686572653a205b4769746875625d2868747470733a2f2f6769746875622e636f6d2f4f70656e5a657070656c696e2f6f70656e7a657070656c696e2d636f6e7472616374732f747265652f6d61737465722f636f6e7472616374732f676f7665726e616e636529205b446f63735d2868747470733a2f2f646f63732e6f70656e7a657070656c696e2e636f6d2f636f6e7472616374732f342e782f6170692f676f7665726e616e636529205b4d6f726520696e666f5d2868747470733a2f2f6f70656e7a657070656c696e2e6e6f74696f6e2e736974652f436f6d706172696e672d436f6d706f756e642d476f7665726e6f722d746f2d4f70656e5a657070656c696e2d476f7665726e6f722d322d31306430666463663631626134373666616534393262323935383232656531332920204173206d656e74696f6e656420696e207468652070726576696f757320436f6e73656e73757320436865636b2c2077652068617665206465706c6f7965642074686520636f6e7472616374206f6e2074686520526f707374656e2074657374206e657420666f722074686520636f6d6d756e69747920746f20726576696577206f757220636f64653a205b476f7665726e6f7220427261766f2044656c656761746f725d2868747470733a2f2f726f707374656e2e65746865727363616e2e696f2f616464726573732f30783135646631356361616431326164616130333934393031346261356363343961383438303364306623636f646529205b476f7665726e6f7220427261766f2044656c65676174655d2868747470733a2f2f726f707374656e2e65746865727363616e2e696f2f616464726573732f30784438626636306466433531313546366342393962623530353032333436453762383633383030663123636f646529205b47697468756220666f7220636f6e7472616374735d2868747470733a2f2f6769746875622e636f6d2f6765747474792f756e69737761702d676f762920202a4e423a2054686520605f696e697469617465602066756e6374696f6e20686173206265656e20736c696768746c79206d6f64696669656420746f2074616b6520616e20696e697469616c2070726f706f73616c206e756d62657220617320616e20696e70757420726174686572207468616e2070756c6c696e672069742066726f6d20476f7665726e6f7220416c7068612e20546869732077617920556e69737761702063616e20726573756d652070726f7065722070726f706f73616c206e756d626572696e672e2a20202323205265736f75726365206c696e6b733a2020312e205b476f7665726e6f7220427261766f20446576656c6f706d656e74202d2050726f746f636f6c20446576656c6f706d656e74202d20436f6d706f756e6420436f6d6d756e69747920466f72756d205d2868747470733a2f2f7777772e636f6d702e78797a2f742f676f7665726e6f722d627261766f2d646576656c6f706d656e742f3934322920322e205b556e6465727374616e64696e6720476f7665726e6f7220427261766f2e204120726576696577206f66206b6579206368616e67657320766572737573a680e2207c206279206d6f6e6574737570706c79207c2054616c6c79207c204a756c2c2032303231207c204d656469756d205d2868747470733a2f2f6d656469756d2e636f6d2f74616c6c792d626c6f672f756e6465727374616e64696e672d676f7665726e6f722d627261766f2d3639623036663138373564612920332e205b436f6d706f756e64207c2050726f706f73616c2044657461696c20233432205d2868747470733a2f2f636f6d706f756e642e66696e616e63652f676f7665726e616e63652f70726f706f73616c732f34322920342e205b436f6d706f756e64207c2050726f706f73616c2044657461696c202334335d2868747470733a2f2f636f6d706f756e642e66696e616e63652f676f7665726e616e63652f70726f706f73616c732f34332922), code=INVALID_ARGUMENT, version=strings/5.7.0) at Logger.makeError (.../node_modules/@ethersproject/logger/src.ts/index.ts:269:28) at Logger.throwError (.../node_modules/@ethersproject/logger/src.ts/index.ts:281:20) at Logger.throwArgumentError (.../node_modules/@ethersproject/logger/src.ts/index.ts:285:21) at errorFunc (.../node_modules/web3-eth-abi/node_modules/@ethersproject/strings/src.ts/utf8.ts:56:19) at getUtf8CodePoints (.../node_modules/web3-eth-abi/node_modules/@ethersproject/strings/src.ts/utf8.ts:144:22) at toUtf8String (.../node_modules/web3-eth-abi/node_modules/@ethersproject/strings/src.ts/utf8.ts:290:26) at StringCoder.decode (.../node_modules/web3-eth-abi/node_modules/@ethersproject/abi/src.ts/coders/string.ts:23:28) at .../node_modules/web3-eth-abi/node_modules/@ethersproject/abi/src.ts/coders/array.ts:96:31 at Array.forEach () at unpack (.../node_modules/web3-eth-abi/node_modules/@ethersproject/abi/src.ts/coders/array.ts:89:12) { reason: 'invalid codepoint at offset 2669; unexpected continuation byte', code: 'INVALID_ARGUMENT', argument: 'bytes', value: Uint8Array(6641) [ 34, 35, 32, 85, 112, 103, 114, 97, 100, 101, 32, 71, 111, 118, 101, 114, 110, 97, 110, 99, 101, 32, 67, 111, 110, 116, 114, 97, 99, 116, 32, 116, 111, 32, 67, 111, 109, 112, 111, 117, 110, 100, 39, 115, 32, 71, 111, 118, 101, 114, 110, 111, 114, 32, 66, 114, 97, 118, 111, 32, 32, 35, 35, 32, 80, 114, 101, 118, 105, 111, 117, 115, 32, 68, 105, 115, 99, 117, 115, 115, 105, 111, 110, 58, 32, 32, 91, 84, 101, 109, 112, 101, 114, 97, 116, 117, 114, 101, 32, 67, ... 6541 more items ], baseType: 'string', type: 'string' }

Expected Behavior

It happened when I tried to get past events with name of event 'ProposalCreated'. Also it doesn't work with 'allEvents'. But it properly works for exapmle for events with name 'ProposalExecuted'.

Steps to Reproduce

import axios from 'axios';
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/naming-convention
const Contract = require('web3-eth-contract');

const getAbi = async (address: string, apiKey: string) => {
  const {data: response} = await axios.get(
    `https://api.etherscan.io/api?module=contract&action=getabi&address=${address}&apikey=${apiKey}`,
  );

  const isAbiValid = response && Number(response.status) === 1;
  if (!isAbiValid) {
    throw new Error('Failed to get abi!');
  }

  return JSON.parse(response.result);
};

const getPastEvents = async (address: string, event: string) => {
  const apiKey = ETHERSCAN_API_KEY;
  const infuraApiKey = INFURA_API_KEY;

  try {
    Contract.setProvider(`https://mainnet.infura.io/v3/${infuraApiKey}`);
    const abi = await getAbi(address, apiKey);
    const contract = new Contract(abi, address);
    const pastEvents = await contract.getPastEvents(event, {
      fromBlock: 0,
      toBlock: 'latest',
    });

    console.log(pastEvents);

    return pastEvents;
  } catch (err) {
    console.error(err);
  }
};

const test = async () => {
  const executedEvents = await getPastEvents('0xc4e172459f1e7939d522503b81afaac1014ce6f6', 'ProposalExecuted');
  console.log(executedEvents);
  const createdEvents = await getPastEvents('0xc4e172459f1e7939d522503b81afaac1014ce6f6', 'ProposalCreated');
  console.log(createdEvents);
};

await test();

Web3.js Version

1.8.0

Environment

Anything Else?

No response

Muhammad-Altabba commented 1 year ago

Hello @Yurii-Pristay, This seems an issue related to having invalid UTF-8 data returned inside a string inside the events log. And we will investigate this further.

Yurii-Pristay commented 1 year ago

Hey, are there any new info on this?

mconnelly8 commented 1 year ago

6/12 - keep

jdevcs commented 1 day ago

@Yurii-Pristay could you narrow down block range where you are getting error?

import { Web3 } from 'web3';

async function test() {
    const web3 = new Web3();

    const con_abi = [
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "id",
                    "type": "uint256"
                }
            ],
            "name": "ProposalCanceled",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "id",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "proposer",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "address[]",
                    "name": "targets",
                    "type": "address[]"
                },
                {
                    "indexed": false,
                    "internalType": "uint256[]",
                    "name": "values",
                    "type": "uint256[]"
                },
                {
                    "indexed": false,
                    "internalType": "string[]",
                    "name": "signatures",
                    "type": "string[]"
                },
                {
                    "indexed": false,
                    "internalType": "bytes[]",
                    "name": "calldatas",
                    "type": "bytes[]"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "startBlock",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "endBlock",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "string",
                    "name": "description",
                    "type": "string"
                }
            ],
            "name": "ProposalCreated",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "id",
                    "type": "uint256"
                }
            ],
            "name": "ProposalExecuted",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "id",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "eta",
                    "type": "uint256"
                }
            ],
            "name": "ProposalQueued",
            "type": "event"
        },
        {
            "anonymous": false,
            "inputs": [
                {
                    "indexed": false,
                    "internalType": "address",
                    "name": "voter",
                    "type": "address"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                },
                {
                    "indexed": false,
                    "internalType": "bool",
                    "name": "support",
                    "type": "bool"
                },
                {
                    "indexed": false,
                    "internalType": "uint256",
                    "name": "votes",
                    "type": "uint256"
                }
            ],
            "name": "VoteCast",
            "type": "event"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "BALLOT_TYPEHASH",
            "outputs": [
                {
                    "internalType": "bytes32",
                    "name": "",
                    "type": "bytes32"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "DOMAIN_TYPEHASH",
            "outputs": [
                {
                    "internalType": "bytes32",
                    "name": "",
                    "type": "bytes32"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [],
            "name": "__acceptAdmin",
            "outputs": [],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                }
            ],
            "name": "cancel",
            "outputs": [],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                },
                {
                    "internalType": "bool",
                    "name": "support",
                    "type": "bool"
                }
            ],
            "name": "castVote",
            "outputs": [],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                },
                {
                    "internalType": "bool",
                    "name": "support",
                    "type": "bool"
                },
                {
                    "internalType": "uint8",
                    "name": "v",
                    "type": "uint8"
                },
                {
                    "internalType": "bytes32",
                    "name": "r",
                    "type": "bytes32"
                },
                {
                    "internalType": "bytes32",
                    "name": "s",
                    "type": "bytes32"
                }
            ],
            "name": "castVoteBySig",
            "outputs": [],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                }
            ],
            "name": "execute",
            "outputs": [],
            "payable": true,
            "stateMutability": "payable",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                }
            ],
            "name": "getActions",
            "outputs": [
                {
                    "internalType": "address[]",
                    "name": "targets",
                    "type": "address[]"
                },
                {
                    "internalType": "uint256[]",
                    "name": "values",
                    "type": "uint256[]"
                },
                {
                    "internalType": "string[]",
                    "name": "signatures",
                    "type": "string[]"
                },
                {
                    "internalType": "bytes[]",
                    "name": "calldatas",
                    "type": "bytes[]"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                },
                {
                    "internalType": "address",
                    "name": "voter",
                    "type": "address"
                }
            ],
            "name": "getReceipt",
            "outputs": [
                {
                    "components": [
                        {
                            "internalType": "bool",
                            "name": "hasVoted",
                            "type": "bool"
                        },
                        {
                            "internalType": "bool",
                            "name": "support",
                            "type": "bool"
                        },
                        {
                            "internalType": "uint96",
                            "name": "votes",
                            "type": "uint96"
                        }
                    ],
                    "internalType": "struct GovernorAlpha.Receipt",
                    "name": "",
                    "type": "tuple"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [
                {
                    "internalType": "address",
                    "name": "",
                    "type": "address"
                }
            ],
            "name": "latestProposalIds",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "name",
            "outputs": [
                {
                    "internalType": "string",
                    "name": "",
                    "type": "string"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "proposalCount",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "proposalMaxOperations",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "pure",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "proposalThreshold",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "pure",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "name": "proposals",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "id",
                    "type": "uint256"
                },
                {
                    "internalType": "address",
                    "name": "proposer",
                    "type": "address"
                },
                {
                    "internalType": "uint256",
                    "name": "eta",
                    "type": "uint256"
                },
                {
                    "internalType": "uint256",
                    "name": "startBlock",
                    "type": "uint256"
                },
                {
                    "internalType": "uint256",
                    "name": "endBlock",
                    "type": "uint256"
                },
                {
                    "internalType": "uint256",
                    "name": "forVotes",
                    "type": "uint256"
                },
                {
                    "internalType": "uint256",
                    "name": "againstVotes",
                    "type": "uint256"
                },
                {
                    "internalType": "bool",
                    "name": "canceled",
                    "type": "bool"
                },
                {
                    "internalType": "bool",
                    "name": "executed",
                    "type": "bool"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "address[]",
                    "name": "targets",
                    "type": "address[]"
                },
                {
                    "internalType": "uint256[]",
                    "name": "values",
                    "type": "uint256[]"
                },
                {
                    "internalType": "string[]",
                    "name": "signatures",
                    "type": "string[]"
                },
                {
                    "internalType": "bytes[]",
                    "name": "calldatas",
                    "type": "bytes[]"
                },
                {
                    "internalType": "string",
                    "name": "description",
                    "type": "string"
                }
            ],
            "name": "propose",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": false,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                }
            ],
            "name": "queue",
            "outputs": [],
            "payable": false,
            "stateMutability": "nonpayable",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "quorumVotes",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "pure",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [
                {
                    "internalType": "uint256",
                    "name": "proposalId",
                    "type": "uint256"
                }
            ],
            "name": "state",
            "outputs": [
                {
                    "internalType": "enum GovernorAlpha.ProposalState",
                    "name": "",
                    "type": "uint8"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "timelock",
            "outputs": [
                {
                    "internalType": "contract TimelockInterface",
                    "name": "",
                    "type": "address"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "uni",
            "outputs": [
                {
                    "internalType": "contract UniInterface",
                    "name": "",
                    "type": "address"
                }
            ],
            "payable": false,
            "stateMutability": "view",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "votingDelay",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "pure",
            "type": "function"
        },
        {
            "constant": true,
            "inputs": [],
            "name": "votingPeriod",
            "outputs": [
                {
                    "internalType": "uint256",
                    "name": "",
                    "type": "uint256"
                }
            ],
            "payable": false,
            "stateMutability": "pure",
            "type": "function"
        }
    ];

    const ProposalCreatedEventBlock = 13059343;
    const ProposalExecutedEventBlock = 13114754;

    const contract1 = new web3.eth.Contract(con_abi, "0xc4e172459f1e7939d522503b81afaac1014ce6f6");
    const pastEvents = await contract1.getPastEvents('ProposalCreated' //'ProposalExecuted'
        , {
            fromBlock:   ProposalCreatedEventBlock - 3000,
            toBlock: ProposalCreatedEventBlock + 3000,
        });

    console.log(pastEvents);
}

test();

// propose function triggers ProposalCreated
// execute function triggers ProposalExecuted