Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wengchaoxi/go-lottery
A Go language program for fair random drawing based on future events. 基于未来事件进行公正随机抽奖的 Go 语言程序。
https://github.com/wengchaoxi/go-lottery
blockchain btc go lottery random
Last synced: 22 days ago
JSON representation
A Go language program for fair random drawing based on future events. 基于未来事件进行公正随机抽奖的 Go 语言程序。
- Host: GitHub
- URL: https://github.com/wengchaoxi/go-lottery
- Owner: wengchaoxi
- License: mit
- Created: 2024-01-29T11:20:09.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-01-29T11:39:47.000Z (10 months ago)
- Last Synced: 2024-06-21T14:29:48.831Z (5 months ago)
- Topics: blockchain, btc, go, lottery, random
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Lottery
**English** | [简体中文](./README.zh-CN.md)
## Overview
Go Lottery determines winners by hashing the unique identifiers of all participants and comparing them to the hash of an unpredictable and publicly verifiable event (such as the hash of a BTC block at a future point in time). The participant whose hash value is closest to that of the event is declared the winner.
Advantages:
- True Randomness: The lottery results are tied to an unpredictable future event (e.g., the hash of a future BTC block), ensuring true randomness.
- Public Verification: As the random event (e.g., the hash of a future BTC block) is publicly available, the fairness of the results can be monitored and verified by the public.
## Usage
```go
package mainimport "github.com/wengchaoxi/go-lottery/lottery"
func main() {
lot := lottery.NewLottery()timeStr := "2024/01/01-00:00:00"
randomEvent := lottery.BTCBlockInfo(timeStr, "2006/01/02-15:04:05")
lot.SetRandomEvent(randomEvent)participants := []string{"Alice", "Bob", "Charlie", "Dave"}
lot.Run(participants)
lot.PrintWinner()
}
```## Attribution
This program design was originally inspired from the work at [peng-zhihui/BilibiliLottery](https://github.com/peng-zhihui/BilibiliLottery)