最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

solidity - Chainlink VRF: Created Subscription ID Mismatch Between On-Chain and Dashboard - Stack Overflow

programmeradmin2浏览0评论

I'm encountering an issue where the subscription ID returned by my script is different from the one shown on vrf.chain.link for the Sepolia network, which when i try to fund to the subid from my script will result InvalidSubscriptionId.

Testcreatesubscription.s.sol:

// SPDX-License-Identifier: MIT

pragma solidity  ^0.8.19;
import {Script} from "fe-std/Script.sol";
import {CodeConstants} from "script/HelperConfig.s.sol";
import {IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import {console} from "fe-std/console.sol";

contract CreateSubscription is Script,CodeConstants{
    function run() public{
        createsubscription_onsepolia();
    }

    function createsubscription_onsepolia() public {
        if(block.chainid == ETH_SEPOLIA_CHAN_ID){
            vm.startBroadcast(0x57099326F00d72E00dc4416FF638136853E5330e);
            uint256 subid = IVRFCoordinatorV2Plus(0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B).createSubscription();
            vm.stopBroadcast();
            console.log("subid on sepolia: ",subid);
        }
    }
}

when i run fe script script/Testcreatesubscription.s.sol:CreateSubscription --rpc-url $SEPOLIA_RPC_URL --account sepolia_testing_account --broadcast -vvvv

sepolia_testing_account is my metamask account, which I have stored in the keystore.

logs result:

== Logs == subid on sepolia: 1756636573672805867076888413.....

Setting up 1 EVM.

Simulated On-chain Traces:

[88720] VRFCoordinatorV2_5::createSubscription() ├─ emit SubscriptionCreated(subId: 175663657367280586707688841388762055..... [1.756e76], owner: 0x57099....) └─ ← [Return] 1756636573672805867076888413887... [1.756e76]

==========================

Chain 11155111

Estimated gas price: 0.724514652 gwei

Estimated total gas used for script: 151638

Estimated amount required: 0.000109863952799976 ETH

========================== Enter keystore password:⠂ Sequence #1 on sepolia

sepolia ✅ [Success] Hash: 0x93a569514837d5d7dd8f525e1fdf105b541fde506522cf9c6b7d0173779c0da7 Block: 8028451 Paid: 0.000043162465117744 ETH (109784 gas * 0.393158066 gwei)

✅ Sequence #1 on sepolia | Total Paid: 0.000043162465117744 ETH (109784 gas * avg 0.393158066 gwei)

Even though the script logs show that my subscription ID is 175663657367280586707688841388762055..., when I check vrf.chain.link on the Sepolia network, I see a completely different subscription ID: 426994294831235659204431318963817900788974.....

I've been struggling with this for hours, and even ChatGPT couldn't figure it out. Does anyone know what I might be doing wrong? Any help would be greatly appreciated!

I'm encountering an issue where the subscription ID returned by my script is different from the one shown on vrf.chain.link for the Sepolia network, which when i try to fund to the subid from my script will result InvalidSubscriptionId.

Testcreatesubscription.s.sol:

// SPDX-License-Identifier: MIT

pragma solidity  ^0.8.19;
import {Script} from "fe-std/Script.sol";
import {CodeConstants} from "script/HelperConfig.s.sol";
import {IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol";
import {console} from "fe-std/console.sol";

contract CreateSubscription is Script,CodeConstants{
    function run() public{
        createsubscription_onsepolia();
    }

    function createsubscription_onsepolia() public {
        if(block.chainid == ETH_SEPOLIA_CHAN_ID){
            vm.startBroadcast(0x57099326F00d72E00dc4416FF638136853E5330e);
            uint256 subid = IVRFCoordinatorV2Plus(0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B).createSubscription();
            vm.stopBroadcast();
            console.log("subid on sepolia: ",subid);
        }
    }
}

when i run fe script script/Testcreatesubscription.s.sol:CreateSubscription --rpc-url $SEPOLIA_RPC_URL --account sepolia_testing_account --broadcast -vvvv

sepolia_testing_account is my metamask account, which I have stored in the keystore.

logs result:

== Logs == subid on sepolia: 1756636573672805867076888413.....

Setting up 1 EVM.

Simulated On-chain Traces:

[88720] VRFCoordinatorV2_5::createSubscription() ├─ emit SubscriptionCreated(subId: 175663657367280586707688841388762055..... [1.756e76], owner: 0x57099....) └─ ← [Return] 1756636573672805867076888413887... [1.756e76]

==========================

Chain 11155111

Estimated gas price: 0.724514652 gwei

Estimated total gas used for script: 151638

Estimated amount required: 0.000109863952799976 ETH

========================== Enter keystore password:⠂ Sequence #1 on sepolia

sepolia ✅ [Success] Hash: 0x93a569514837d5d7dd8f525e1fdf105b541fde506522cf9c6b7d0173779c0da7 Block: 8028451 Paid: 0.000043162465117744 ETH (109784 gas * 0.393158066 gwei)

✅ Sequence #1 on sepolia | Total Paid: 0.000043162465117744 ETH (109784 gas * avg 0.393158066 gwei)

Even though the script logs show that my subscription ID is 175663657367280586707688841388762055..., when I check vrf.chain.link on the Sepolia network, I see a completely different subscription ID: 426994294831235659204431318963817900788974.....

I've been struggling with this for hours, and even ChatGPT couldn't figure it out. Does anyone know what I might be doing wrong? Any help would be greatly appreciated!

Share Improve this question asked Apr 2 at 3:38 Phc Chu Vaky RamadanPhc Chu Vaky Ramadan 31 bronze badge New contributor Phc Chu Vaky Ramadan is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

The subscription ID returned by IVRFCoordinatorV2Plus(0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B).createSubscription(); when executing the Foundry script is not necessarily the actual subscription ID created on the VRF Dashboard.

This is because the returned value comes from a simulated execution before the transaction is confirmed on-chain. Foundry simulates the return value before the transaction is mined, which can result in a discrepancy between the simulated value and the actual on-chain value.

Therefore, you must retrieve the actual value either from the transaction logs via a block explorer or directly from the VRF Dashboard.

发布评论

评论列表(0)

  1. 暂无评论