This work is devoted to the creation of an online auction based on the blockchain network.
The consensus underlying the network is PoW.
To install Go visit site:
To install gorilla/mux:
go get github.com/gorilla/mux
go run Main.go <port_to_listen>
(For example go run Main.go 9000
)
Run postman and invoke API Methods
You can use Postman to work with the API.
To install Postman:
$ sudo apt update
$ sudo apt install snapd
$ sudo snap install postman
Path:
localhost:9000/bid/broadcast
POST body:
{
"bidder_name": "Andrew",
"auction_id": 1,
"bid_value,string": "1.25"
}
Response body:
{
"Name": "RegisterAndBroadcastBid"
,
"Status": "Bid created and broadcast successfully",
"Time": "2022-06-23T19:12:08.88213331+03:00"
}
To check, you can use the link and see the pending bids.
Path:
localhost:9000/blockchain
Response body:
{
"chain": [
{
"block_id": 1,
"block_timestamp": 1656001600038743150,
"bids": [],
"nonce": 100,
"hash": "0",
"previous_block_hash": "0"
}
],
"pending_bids": [
{
"bidder_name": "Anton",
"auction_id": 1,
"bid_value": "1.25"
}
],
"network_nodes": {}
}