chesslablab / chess-api

REST-like chess API.
https://chesslablab.github.io/chess-api/
MIT License
23 stars 10 forks source link

Upload a chess game into the InterPlanetary File System #78

Closed programarivm closed 1 year ago

programarivm commented 1 year ago

Let's upload the very first chess game in JSON format into IPFS! Any of the games in data/annotations/games.json should be okay. Let's start with the following one.

{
    "Event": "Steinitz - Zukertort World Championship Match",
    "Site": "New Orleans, LA USA",
    "Date": "1886",
    "White": "Johannes Zukertort",
    "Black": "Wilhelm Steinitz",
    "WhiteElo": "?",
    "BlackElo": "?",
    "Result": "0-1",
    "ECO": "D50",
    "movetext": "{ Adapted notes, originally by Robert James Fischer from a television interview. } 1.d4 d5 2.c4 e6 3.Nc3 Nf6 4.Bg5 Be7 5.Nf3 O-O 6.c5 { is a mistake already; instead it should be played e3, naturally. } 6...b6 7.b4 bxc5 8.dxc5 a5 9.a3 d4 { is a fantastic move; it's the winning move. The pawn can't be taken with the knight because of axb4. } 10.Bxf6 gxf6 11.Na4 e5 { because the center is easily winning. Black's kingside weakness is nothing. } 12.b5 Be6 { with the idea of dominating the game with a powerful mobile center. } 13.g3 c6 14.bxc6 Nxc6 15.Bg2 Rb8 { threatening Bb3. } 16.Qc1 d3 17.e3 e4 18.Nd2 f5 19.O-O Re8 { is a very modern move; a quiet positional move. The rook is doing nothing now, but later... } 20.f3 { to break up the center, it's the only chance for White. } 20...Nd4 21.exd4 Qxd4+ 22.Kh1 e3 (22... Qxa4 { allows Black to easily regain material. }) 23.Nc3 Bf6 24.Ndb1 d2 25.Qc2 Bb3 26.Qxf5 d1=Q 27.Nxd1 Bxd1 28.Nc3 e2 29.Raxd1 Qxc3 { and White resigns. The center has prevailed. } 0-1"
  }

See https://github.com/orgs/chesslablab/discussions/349

Keep it up,

SmashedFrenzy16 commented 1 year ago

Hi there, happy learning and coding! I will try my best to try and find a way to upload to IPFS.

SmashedFrenzy16 commented 1 year ago

@programarivm, is there any IPFS platform that this organization would like to use? There doesn't seem to be a universal one (at least whatever i've researched).

programarivm commented 1 year ago

Any of the following should be okay.

SmashedFrenzy16 commented 1 year ago

@programarivm, I think we need to create accounts to access these platforms. But would it matter if I just made an account (we only need to pull from the IPFS)?

programarivm commented 1 year ago

Not too sure, I guess at this moment this issue is quite experimental. It'd be nice if you could create an account, upload the file, and share the IPFS url.

Happy learning!

SmashedFrenzy16 commented 1 year ago

@programarivm I have created the account and am going to do the IPFS stuff.

programarivm commented 1 year ago

Thank you @SmashedFrenzy16,

Then at some point the file will be fetched from IFPS:

Keep it up,

SmashedFrenzy16 commented 1 year ago

@programarivm, the maximum transfer limit thorugh IPFS on Infura is 5GB for free. Is this plenty of storage considering the future?

This is what Infura says:

5GB of total storage
No single file upload size restriction
5GB total data transfer down/mo
5GB total data transfer up/mo
CodeMaster7000 commented 1 year ago

@SmashedFrenzy16 Should be fine.

SmashedFrenzy16 commented 1 year ago

@programarivm and @CodeMaster7000, I take it that we probably don't need all of the 5GB, so I'm going to set up the IPFS now on the account.

SmashedFrenzy16 commented 1 year ago

@programarivm I have successfully pinned the JSON file for the game posted at the top of this issue using Infura IPFS (pinning means uploading in IPFS terms)!

SmashedFrenzy16 commented 1 year ago

I also modified the JSON at the top of the issue to move in the closing curly bracket, to match the data/annotations/games.json formatting.

programarivm commented 1 year ago

Thank you @SmashedFrenzy16 for setting up Infura on your side. Can the IPFS link be shared for public access?

SmashedFrenzy16 commented 1 year ago

@programarivm I have a dedicated gateway subdomain from infura for the IPFS API project, which is the following: https://chesslablabgames.infura-ipfs.io

SmashedFrenzy16 commented 1 year ago

@programarivm if that doesn't work, I can share an invite to collaboration on the API key (that isn't public and only intended for specific people and requires and email to send the invite), or I could send the API key and the secret key securely somehow (but this is risky - the first option of an invite seems better).

SmashedFrenzy16 commented 1 year ago

@programarivm, if the public want to have some access to the IPFS if nothing works, there is an API key (since there is also a secret, this one is probably fine for public use). But we can always add files and retrieve files from the IPFS, and if deemed necessary, I can share the project with you so that you can also get uploading rights.

SmashedFrenzy16 commented 1 year ago

@programarivm, if you have found that this process can be simplified, then that would be great!

programarivm commented 1 year ago

If I'm not very much mistaken, I thought a CID would have been created.

See:

This should be okay to close this issue.

Happy learning,

SmashedFrenzy16 commented 1 year ago

I'll try and find the CID and send it here (I presume it is just the file hash by what I've read).

SmashedFrenzy16 commented 1 year ago

@programarivm I think this is the CID:

QmSjSFQYJ547DnUZqQhXRob37eUwxQotbtwbwz9gis7Ebt
programarivm commented 1 year ago

The game can now be fetched from this URL.

https://ipfs.io/ipfs/QmSjSFQYJ547DnUZqQhXRob37eUwxQotbtwbwz9gis7Ebt
{
    "Event": "Steinitz - Zukertort World Championship Match",
    "Site": "New Orleans, LA USA",
    "Date": "1886",
    "White": "Johannes Zukertort",
    "Black": "Wilhelm Steinitz",
    "WhiteElo": "?",
    "BlackElo": "?",
    "Result": "0-1",
    "ECO": "D50",
    "movetext": "{ Adapted notes, originally by Robert James Fischer from a television interview. } 1.d4 d5 2.c4 e6 3.Nc3 Nf6 4.Bg5 Be7 5.Nf3 O-O 6.c5 { is a mistake already; instead it should be played e3, naturally. } 6...b6 7.b4 bxc5 8.dxc5 a5 9.a3 d4 { is a fantastic move; it's the winning move. The pawn can't be taken with the knight because of axb4. } 10.Bxf6 gxf6 11.Na4 e5 { because the center is easily winning. Black's kingside weakness is nothing. } 12.b5 Be6 { with the idea of dominating the game with a powerful mobile center. } 13.g3 c6 14.bxc6 Nxc6 15.Bg2 Rb8 { threatening Bb3. } 16.Qc1 d3 17.e3 e4 18.Nd2 f5 19.O-O Re8 { is a very modern move; a quiet positional move. The rook is doing nothing now, but later... } 20.f3 { to break up the center, it's the only chance for White. } 20...Nd4 21.exd4 Qxd4+ 22.Kh1 e3 (22... Qxa4 { allows Black to easily regain material. }) 23.Nc3 Bf6 24.Ndb1 d2 25.Qc2 Bb3 26.Qxf5 d1=Q 27.Nxd1 Bxd1 28.Nc3 e2 29.Raxd1 Qxc3 { and White resigns. The center has prevailed. } 0-1"
}
SmashedFrenzy16 commented 1 year ago

@programarivm that's great! Should we now make a program to fetch the games from IPFS?

programarivm commented 1 year ago

🙂 Not too sure about how to query the data in the interplanetary file system.