Skip to main content
Version: 2.0

Get events by contract

POSThttps://deep-index.moralis.io/api/v2/:address/events

Get events for a contract ordered by block number in descending order. Try it with Swagger.

PATH PARAMS
addressstringrequired
The address of the contract
QUERY PARAMS
chainstring
The chain to query
from_blocknumber

The minimum block number from which to get the logs

  • Provide the param 'from_block' or 'from_date'
  • If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_blocknumber

The maximum block number from which to get the logs.

  • Provide the param 'to_block' or 'to_date'
  • If 'to_date' and 'to_block' are provided, 'to_block' will be used.
from_datestring

The start date from which to get the logs (any format that is accepted by momentjs)

  • Provide the param 'from_block' or 'from_date'
  • If 'from_date' and 'from_block' are provided, 'from_block' will be used.
to_datestring

Get the logs up to this date (any format that is accepted by momentjs)

  • Provide the param 'to_block' or 'to_date'
  • If 'to_date' and 'to_block' are provided, 'to_block' will be used.
topicstringrequired
The topic of the event
offsetnumber
offset
disable_totalboolean
⚠️ Deprecating soon. If the result should skip returning the total count (Improves performance). This parameter defaults to true.
limitnumber
The desired page size of the result.
BODY PARAM
json
ABI of the specific event
Responses
API KEY
import Moralis from 'moralis';

try {
await Moralis.start({
apiKey: "YOUR_API_KEY"
});

const response = await Moralis.EvmApi.events.getContractEvents({
"chain": "0x1",
"topic": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"address": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984",
"abi": {
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
}
});

console.log(response.raw);
} catch (e) {
console.error(e);
}
Response Example
{
"total": "",
"page": "",
"page_size": "",
"result": [
{
"transaction_hash": "0x2d30ca6f024dbc1307ac8a1a44ca27de6f797ec22ef20627a1307243b0ab7d09",
"address": "0x18F97EF6B2cbac5CA85b375b7093C4A207340d06",
"block_timestamp": "2021-04-02T10:07:54.000Z",
"block_number": 12526958,
"block_hash": "0x0372c302e3c52e8f2e15d155e2c545e6d802e479236564af052759253b20fd86",
"data": ""
}
]
}