ichinose9372 / ft_transcendense_42

3 stars 1 forks source link

ブロックチェーンに保存されていることの確認 #110

Closed ryhara closed 1 week ago

ryhara commented 1 week ago
yuidvg commented 1 week ago

ブロックチェーンに保存されているか確認する手順

  1. Remix IDE にアクセス
  2. 下記の内容でTournamentScore.abiを作成・エディタで開かれている状態にする
    [
    {
        "inputs": [
            {
                "internalType": "string",
                "name": "tournamentId",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "playerId",
                "type": "string"
            },
            {
                "internalType": "uint256",
                "name": "score",
                "type": "uint256"
            }
        ],
        "name": "addScore",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "index",
                "type": "uint256"
            }
        ],
        "name": "getScore",
        "outputs": [
            {
                "internalType": "string",
                "name": "",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "",
                "type": "string"
            },
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    },
    {
        "inputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "name": "scores",
        "outputs": [
            {
                "internalType": "string",
                "name": "matchId",
                "type": "string"
            },
            {
                "internalType": "string",
                "name": "scorerName",
                "type": "string"
            },
            {
                "internalType": "uint256",
                "name": "score",
                "type": "uint256"
            }
        ],
        "stateMutability": "view",
        "type": "function"
    }
    ]
  3. 左メニューから Deploy & run transactionsを選択
  4. At Address欄に 0xd6cc1992c9ff6ee4207a9a3e310c569b6c2249ea を入力
  5. At Addressボタンを押す
  6. Deployed/Unpinned Contracts > AT 0XD6C...249EA (BLOCKCHAIN) > getScore()を確認したいScoreのIndexと共に呼び出す
ryhara commented 1 week ago
for score_data in scores_data:
            match_id = score_data['matchId']
            score_value = score_data['score']
            participant_name = score_data['participantName']

            match = Match.objects.get(match_id=match_id)

            Score.objects.update_or_create(
                match=match,
                participant_name=participant_name,
                defaults={'score': score_value}
            )

print(add_score(scores_data[0]['matchId'], scores_data[0]['participantName'], scores_data[0]['score']))
yuidvg commented 1 week ago

いけそう