Skip to content

Commit 57f5d0b

Browse files
committed
account: add ERC721Transfers()
1 parent 4bf649f commit 57f5d0b

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

account.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@ func (c *Client) ERC20Transfers(contractAddress, address *string, startBlock *in
107107
return
108108
}
109109

110+
// ERC721Transfers get a list of "erc721 - token transfer events" by
111+
// contract address and/or from/to address.
112+
//
113+
// leave undesired condition to nil.
114+
func (c *Client) ERC721Transfers(contractAddress, address *string, startBlock *int, endBlock *int, page int, offset int, desc bool) (txs []ERC721Transfer, err error) {
115+
param := M{
116+
"page": page,
117+
"offset": offset,
118+
}
119+
compose(param, "contractaddress", contractAddress)
120+
compose(param, "address", address)
121+
compose(param, "startblock", startBlock)
122+
compose(param, "endblock", endBlock)
123+
124+
if desc {
125+
param["sort"] = "desc"
126+
} else {
127+
param["sort"] = "asc"
128+
}
129+
130+
err = c.call("account", "tokennfttx", param, &txs)
131+
return
132+
}
133+
110134
// BlocksMinedByAddress gets list of blocks mined by address
111135
func (c *Client) BlocksMinedByAddress(address string, page int, offset int) (mined []MinedBlock, err error) {
112136
param := M{

response.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,29 @@ type ERC20Transfer struct {
8888
Confirmations int `json:"confirmations,string"`
8989
}
9090

91+
// ERC721Transfer holds info from ERC721 token transfer event query
92+
type ERC721Transfer struct {
93+
BlockNumber int `json:"blockNumber,string"`
94+
TimeStamp Time `json:"timeStamp"`
95+
Hash string `json:"hash"`
96+
Nonce int `json:"nonce,string"`
97+
BlockHash string `json:"blockHash"`
98+
From string `json:"from"`
99+
ContractAddress string `json:"contractAddress"`
100+
To string `json:"to"`
101+
TokenID *BigInt `json:"tokenID"`
102+
TokenName string `json:"tokenName"`
103+
TokenSymbol string `json:"tokenSymbol"`
104+
TokenDecimal uint8 `json:"tokenDecimal,string"`
105+
TransactionIndex int `json:"transactionIndex,string"`
106+
Gas int `json:"gas,string"`
107+
GasPrice *BigInt `json:"gasPrice"`
108+
GasUsed int `json:"gasUsed,string"`
109+
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
110+
Input string `json:"input"`
111+
Confirmations int `json:"confirmations,string"`
112+
}
113+
91114
// MinedBlock holds info from query for mined block by address
92115
type MinedBlock struct {
93116
BlockNumber int `json:"blockNumber,string"`

0 commit comments

Comments
 (0)