Skip to content

Commit 49eaf79

Browse files
committed
add GetLogs
1 parent 31968a8 commit 49eaf79

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

logs.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package etherscan
2+
3+
// GetLogs gets a list of log for a single address
4+
// startBlock and endBlock cann`t be nil
5+
func (c *Client) GetLogs(address string, fromBlock string, toBlock string, topic0 string) (logs []Log, err error) {
6+
param := M{
7+
"fromBlock": fromBlock,
8+
"toBlock": toBlock,
9+
"topic0": topic0,
10+
}
11+
compose(param, "address", address)
12+
err = c.call("logs", "getLogs", param, logs)
13+
return
14+
}

response.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,29 @@ type LatestPrice struct {
136136
ETHUSD float64 `json:"ethusd,string"`
137137
ETHUSDTimestamp Time `json:"ethusd_timestamp"`
138138
}
139+
140+
type Log struct {
141+
// Consensus fields:
142+
// address of the contract that generated the event
143+
Address string `json:"address" `
144+
// list of topics provided by the contract.
145+
Topics []string `json:"topics"`
146+
// supplied by the contract, usually ABI-encoded
147+
Data []byte `json:"data"`
148+
149+
// Derived fields. These fields are filled in by the node
150+
// but not secured by consensus.
151+
// block in which the transaction was included
152+
BlockNumber string `json:"blockNumber"`
153+
GasPrice string `json:"gasPrice"`
154+
GasUsed string `json:"gasUsed"`
155+
TimeStamp string `json:"timeStamp"`
156+
// hash of the transaction
157+
TxHash string `json:"transactionHash"`
158+
// index of the transaction in the block
159+
TxIndex string `json:"transactionIndex"`
160+
// hash of the block in which the transaction was included
161+
BlockHash string `json:"blockHash"`
162+
// index of the log in the block
163+
Index string `json:"logIndex"`
164+
}

0 commit comments

Comments
 (0)