---
title: 連線遠端的 flow node
tags: work_mike
---
## 1. 連線方法
* 目前方式:
* 利用flowclient與公用節點連線
```
flowClient, err := client.New("access.mainnet.nodes.onflow.org:9000", grpc.WithInsecure())
```
* Get Block by Height
```
block, err := flowClient.GetBlockByHeight(context.background(), blockHeight)
```
* Get Block event by IDs
```
block, err := flowClient.GetEventsForBlockIDs(context.Background(),"AA.1654653399040a61.FlowToken.TokensWithdrawn", blockIds)
```
* Get Block event by a range
```
bkEvent, err :=flowClient.GetEventsForHeightRange(context.Background(), client.EventRangeQuery{
Type: "A.1654653399040a61.FlowToken.TokensWithdrawn",
StartHeight: 13366442,
EndHeight: 13366444,
})
```
這個Function Range 太大時(超過300),經常發生不work的狀況
## 2. 所有Print 出來的結果
### 將event
將event print 出來的結果
```
A.1654653399040a61.FlowToken.TokensWithdrawn(amount: 0.00100000, from: 0x47fd53250cc3982f)
```
透過以上的方法就可以拿到Block的Event,而Event的種類就要依照每個合約所提供的來拿取
需要注意 官方提供的SDK是依照Block裡面的事件一個一個搜尋,而不是搜尋Block內的所有事件,這個後續建立SQL時需要討論一下。
* 目前觀察到的合約
* [FlowToken](https://flowscan.org/contract/A.1654653399040a61.FlowToken)
* TokensInitialized(initialSupply: UFix64) 當合約建立時
* 初始Suppply數量
* TokensWithdrawn (amount: UFix64, from: Address?) Token被取消時
* 回傳 數量、地址
* TokensDeposited(amount: UFix64, to: Address?) Token被存入時
* 回傳數量以及地址
* TokensMinted Token鑄造時
* 回傳數量
* TokensBurned Token被銷毀時
* 回傳數量
* MinterCreated 鑄造者被創造時
* 回傳數量
* BurnerCreated 銷毀者被創造時
* [Evolution](https://flowscan.org/contract/A.f4264ac8f3256818.Evolution)
* ItemCreated 物件被創造時
* 回傳 物件ID 以及資料
* NewSeriesStarted 新的系列被創造
* 回傳系列ID
* SetCreated set被創造
* 回傳SetId 以及Series ID
* ItemAddedToSet Item被加入Set中
* set Id ,item Id
* ItemRetiredFromSet Item從集合退出時且不能被鑄造
* 回傳setID itemID minted數量
* SetLocked set被Lock
* 回傳set ID
* CollectibleMinted 收藏品被鑄造
* 回傳 id,item id, setid,serialNumber
* CollectibleDestroyed 收藏品被刪除時
* 回傳集合id
* Withdraw 收藏品從收藏中被撤回
* 回傳id,address
* Deposit 商藏品被加入收藏中
* 回傳id,address
* [VIV3]("https://flowscan.org/contract/A.c2d564119d2e5c3d.VIV3")
* TokenListed Token 被List上Viv3
* 回傳 Id,price,seller
* TokenPriceChanged Token價錢改變
* 回傳 Id ,price,seller
* TokenPurchased Token被購買
* 回傳Id, price,seller
* TokenWithdraw Token被取消
* 回傳Id,address
* FeeChange fee改變
* 回傳fee,seller
* RoyaltyChanged Royalty改變
* 回傳Royalty價錢,seller
* [Topshot]("https://flowscan.org/contract/A.0b2a3299cc857e29.TopShot")
* PlayCreated Player 被創造
* 回傳ID,Player Infomation
* NewSeriesStarted 管理員推出新系列
* 回傳新系列的ID
* SetCreated 新的set被創造
* 回傳 setid ,series
* PlayAddedToSet a play add to set
* 回傳setId ,PlayId
* PlayRetiredFromSet Play被從set退出時
* 回傳SetId,PlayID,numMoments
* SetLocked Lock set讓其不能被新增減少
* 回傳SetId
* MomentMinted 當Moment卡被創造時
* 回傳 MomentID,PlayID,setId,serialNumber
* Withdraw 當moment 被取消
* 回傳 Id ,address
* Deposit 當moment
* 回傳ID,address
* MomentDestroyed moment 被刪除
* 回傳 Id
* Total supportly 總數量
* [Market]("https://flowscan.org/contract/A.c1e4f4f4c4257510.Market")
* MomentListed moment 上架販賣
* 回傳 Id ,Price,seller
* MomentPriceChange Moment 價格改變
* 回傳 Id,newPrice,seller
* MomentPurchased moment 被購買
* 回傳 id ,price,seller
* MomentWithdraw moment 被withdraw
* 回傳 id , owner
* CutPercentageChanged 所有者更改了銷售百分比
* 回傳newPercent,seller