Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I followed official docs of V2.5 to construct my contracts, when testing locally, everything seems fine, but calling request function on Sepolia test net is always getting reverted, here's my repo for NFT Project

Things I've tried:

  1. I funded my subscription and tried to use VRFD20 example contract from official site, rollDice works, so my subscription should be good
    image
    The first one is my NFT contract, the second is the VRFD20 contract I deployed from Remix
  2. Tried to determine why it was reverted, but the decoded variable is null, this is probably not related to the actual problem, but it's the reason that I don't know what was going on.
    const randomNftArtifact = JSON.parse(
        fs.readFileSync(
            path.join(
                __dirname,
                "../artifacts/contracts/RandomIpfsNft.sol/RandomIpfsNft.json",
            ),
            "utf-8",
        ),
    );
    const randomNftAbi = randomNftArtifact.abi;
    const randomNftInterface = new ethers.Interface(randomNftAbi);
    
    await new Promise(async (resolve, reject) => {
        randomIpfsNft.once("NftFulfilled", async () => {
            resolve();
        });
    
        try {
            const requestRandomNftTxn = await randomIpfsNft
                .connect(deployer)
                .requestNft({
                    value: randomMintFee,
                });
            const requestRandomNftTxnReceipt = requestRandomNftTxn.wait(1);
        } catch (error) {
            const decoded = randomNftInterface.parseError(error.data);
            console.log(decoded);
            reject();
        }
    });
  3. Tried on etherscan, also reverted

Contract snippet

function requestNft()
        public
        payable
        enoughMintFee
        returns (uint256 requestId)
    {
        requestId = s_vrfCoordinator.requestRandomWords(
            VRFV2PlusClient.RandomWordsRequest({
                keyHash: i_keyHash,
                subId: i_subscriptionId,
                requestConfirmations: i_requestConfirmations,
                callbackGasLimit: i_callbackGasLimit,
                numWords: i_numWords,
                extraArgs: VRFV2PlusClient._argsToBytes(
                    VRFV2PlusClient.ExtraArgsV1({nativePayment: false})
                )
            })
        );

        emit NftRequested(requestId, msg.sender);
        s_requestIdToSender[requestId] = msg.sender;
    }

Edit: I am using hardhat-ignition for this project, to deploy and run locally, please refer to package.json:

"scripts": {
        "h-compile": "hardhat compile",
        "h-clean": "hardhat clean",
        "h-test": "hardhat test",
        "h-test-s": "hardhat test --network sepolia",
        "h-node": "hardhat node",
        "h-i-deploy": "hardhat ignition deploy",
        "h-s-deploy": "hardhat run scripts/deploy.js",
        "h-verify": "hardhat ignition verify",
        "h-run": "hardhat run"
    },

To deploy/run on Sepolia, I used NETWORK=sepolia for terminal env variable:

NETWORK=sepolia yarn h-run scripts/mint.js --network sepolia
let currentNetwork = process.env.NETWORK || "hardhat";
if (currentNetwork === "localhost") {
    currentNetwork = "hardhat";
}
const localFlag = devChains.includes(currentNetwork);

Please help!!!

You must be logged in to vote

Replies: 1 comment

Comment options

@Marcrus813 have you found a solution to this?

I am experiencing the same issue

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.