Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,29 @@
package etherscan

// GetLogs gets logs that match "topic" emitted by the specified "address" between the "fromBlock" and "toBlock"
func (c *Client) GetLogs(fromBlock, toBlock int, address, topic string) (logs []Log, err error) {
func (c *Client) GetLogs(address string, fromBlock, toBlock *int, topic *string, page, offset *int) (logs []Log, err error) {
param := M{
"fromBlock": fromBlock,
"toBlock": toBlock,
"topic0": topic,
"address": address,
"address": address,
}

if fromBlock != nil {
param["fromBlock"] = *fromBlock
}

if toBlock != nil {
param["toBlock"] = *toBlock
}

if topic != nil {
param["topic0"] = *topic
}

if page != nil {
param["page"] = *page
}

if offset != nil {
param["offset"] = *offset
}

err = c.call("logs", "getLogs", param, &logs)
Expand Down
6 changes: 5 additions & 1 deletion logs_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ func TestClient_GetLogs(t *testing.T) {
},
}

actualLogs, err := api.GetLogs(379224, 379225, "0x33990122638b9132ca29c723bdf037f1a891a70c", "0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545")
fromBlock := 379224
toBlock := 379225
topic := "0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545"

actualLogs, err := api.GetLogs("0x33990122638b9132ca29c723bdf037f1a891a70c", &fromBlock, &toBlock, &topic, nil, nil)

noError(t, err, "api.GetLogs")

Expand Down