Code here will be used in Learn-Anything.xyz
Was done as part of Solana Hacker House Berlin.
go run main.go
Using bun
cd website
bun run dev
with some default SOL balance:
curl -X POST http://127.0.0.1:8080/users -H "Content-Type: application/json" -d '{"id": 2,"name":"John Updated", "email":"[email protected]"}'
curl -X GET http://localhost:8080/users/8
{"bought_products":null,"created_products":[{"id":3,"product_name":"Chair"},{"id":4,"product_name":"Laptop"}],"email":"[email protected]","id":8,"name":"John Updated","wallet":"GrrG9YS4C9EwtWanHQYMejF5UqBXSjQ42qAWjNRy5CyX"}
curl -X POST http://localhost:8080/pay \
-H "Content-Type: application/json" \
-d '{"source_user_id": 1, "target_user_id": 2, "product_id": 300}'
it will return transaction id:
{"tix":"3kvAHBE25xQ4eYE6BMsnHuYwwszds5Z1f9KcVnwCVWnUfzdm8EDTQetcpdjzhzrUWfd54aF5MFfiMEy65LtWoatt"}
curl -X POST http://127.0.0.1:8080/balance -H "Content-Type: application/json" -d '{"user_id": 2}'
{"balance":"1.0000000000","balance_usd":"19.59"}
curl -X POST http://localhost:8080/goods \
-H "Content-Type: application/json" \
-d '{"name": "Book", "price": 1, "created_by": 11}'
curl -X GET http://localhost:8080/goods/2
{"id":2,"product_name":"Chair","count":1}
curl -X POST http://localhost:8080/can-i-buy \
-H "Content-Type: application/json" \
-d '{"user_id": 7, "product_id": 5}'
{"result":true}
curl -X GET http://localhost:8080/goods\?user_id=8
sqlite3 test.db
.tables
.schema user_goods