mowblox / emt-marketplace

The goal is to help people become really good at what they do through decentralized mentorship.
https://emt-marketplace.vercel.app
Apache License 2.0
1 stars 3 forks source link

Unable to read data from contracts deployed to Topos Testnet #37

Closed Jovells closed 9 months ago

Jovells commented 9 months ago

I get this error whenever I try to read data from the topos contract:

errors.js:124 Uncaught (in promise) Error: could not decode result data (value="0x", info={ "method": "contentVotes", "signature": "contentVotes(bytes32)" }, code=BAD_DATA, version=6.9.0)
    at makeError (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/utils/errors.js:137:21)
    at assert (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/utils/errors.js:156:15)
    at Interface.decodeFunctionResult (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/abi/interface.js:792:64)
    at staticCallResult (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/contract/contract.js:265:35)
    at async staticCall (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/contract/contract.js:230:24)
    at async Proxy.contentVotes (webpack-internal:///(app-pages-browser)/./node_modules/ethers6/lib.esm/contract/contract.js:270:20)

Writing to the contracts works fine, however. But I realised that the transaction receipt after writing to the topos network comes with no logs.

Transaction Receipt from creating a post On Topos Network:

    "_type": "TransactionReceipt",
    "blockHash": "0xa43639e1748d9bd404ecf6aeb45bd74e8b7907efdb2baff7ceb3d34fafdfc097",
    "blockNumber": 26255,
    "contractAddress": null,
    "cumulativeGasUsed": "21432",
    "from": "0xf7A4aaA6824bd6a6f7Fb1478F7319A6538d8CCbC",
    "gasPrice": "1433300",
    "gasUsed": "21432",
    "hash": "0x1404db761197064c4a134bcd2f30d43d74b3c1804fa89ce858e45a3c6bc5f5df",
    "index": 0,
//🔴empty logs
    "logs": [],
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "root": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "status": 1,
    "to": "0x169D209c8210F11e292BA9D923525A29A9759787"
}

Transaction receipt from creating a post on polygon mumbai:

{
    "_type": "TransactionReceipt",
    "blockHash": "0x67f11b51d47a846c7fe582459c70150bdc74c55a3db639f03102e0d937abb1f1",
    "blockNumber": 43237872,
    "contractAddress": null,
    "cumulativeGasUsed": "289710",
    "from": "0xDb9ebFe6092f8B3Cb22A6236c69ca460fA1a4aE1",
    "gasPrice": "1500000015",
    "gasUsed": "45941",
    "hash": "0xd1a9d43174ecacefb7da1bf90f42a5da8a3eac5be155899b161bfae281b75db0",
    "index": 3,
  //🔴logs` as expecteed
    "logs": [
        {
            "_type": "log",
            "address": "0xcc484A378714d5Eb7608280d5f2693A9A87116B7",
            "blockHash": "0x67f11b51d47a846c7fe582459c70150bdc74c55a3db639f03102e0d937abb1f1",
            "blockNumber": 43237872,
            "data": "0x417452323442726751516439434c4532774b6c31000000000000000000000000",
            "index": 8,
            "topics": [
                "0x71d58f643edf3d402ab8476ecd4351de00374789657d01019787587ed82d5e9c",
                "0x000000000000000000000000db9ebfe6092f8b3cb22a6236c69ca460fa1a4ae1"
            ],
            "transactionHash": "0xd1a9d43174ecacefb7da1bf90f42a5da8a3eac5be155899b161bfae281b75db0",
            "transactionIndex": 3
        },
        {
            "_type": "log",
            "address": "0x0000000000000000000000000000000000001010",
            "blockHash": "0x67f11b51d47a846c7fe582459c70150bdc74c55a3db639f03102e0d937abb1f1",
            "blockNumber": 43237872,
            "data": "0x00000000000000000000000000000000000000000000000000003eacb57a7b0000000000000000000000000000000000000000000000000022c3eae6c32b1d8f00000000000000000000000000000000000000000000001e5a7391ae636db4da00000000000000000000000000000000000000000000000022c3ac3a0db0a28f00000000000000000000000000000000000000000000001e5a73d05b18e82fda",
            "index": 9,
            "topics": [
                "0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63",
                "0x0000000000000000000000000000000000000000000000000000000000001010",
                "0x000000000000000000000000db9ebfe6092f8b3cb22a6236c69ca460fa1a4ae1",
                "0x00000000000000000000000004ba3ef4c023c1006019a0f9baf6e70455e41fcf"
            ],
            "transactionHash": "0xd1a9d43174ecacefb7da1bf90f42a5da8a3eac5be155899b161bfae281b75db0",
            "transactionIndex": 3
        }
    ],
    "logsBloom": "0x00000000000000000000000000000004000000000000000000000000000004800000000000000000000000000000000000008008000000000000000000000000000000000000000000000000000800800000000000080000000100000000000000000000000000000000000000000000000000000000000080000000000000000000000000004000000008000000000000000000800000000000000000000000200000000000000000000000000000000000000000000000000000000000004000000000000000000001000000000000000000000000000000100000000000000000000000000000000000000000002000000000000000000000000000300000",
    "status": 1,
    "to": "0xcc484A378714d5Eb7608280d5f2693A9A87116B7"
}

steps to reproduce:

  1. set NEXT_PUBLIC_DEVCHAIN to 2359 in .env.development to use topos chain. ( The folder names in frontend/nextjs/src/deployments represent the chains ids for the chains to which the contract has deployed. This value can be set to any of them)
  2. start project.
  3. I have temporarily exposed the contract objects on the window object in contracts.js, line 96) so you can interact with it from the browser console (Eg: EMTMarketPlace.mentTokenAddress())

@mickeymond @od41

Jovells commented 9 months ago

@mickeymond helped discover that there was a scheduled topos testnet reset which wiped out the deployed contracts, causing this error. I redeployed and the issue was fixed.

This commit fixes it: https://github.com/mowblox/emt-marketplace/pull/38/commits/f57b90409caeb12cdb8ea55e3a2f9d332f77230a