peterduhon / skia-poker-morph

Trustless Tricksters: A decentralized poker game built on Morph zkEVM. Featuring secure card shuffling, Chainlink VRF for fairness, Galadriel AI agents, XMTP chat, and Web3Auth login. Experience the future of poker on the blockchain. ๐Ÿƒ๐Ÿ”๐Ÿš€
3 stars 0 forks source link

[SP-20] - Research LINK Token and VRF Coordinator on Morph Testnet #10

Open peterduhon opened 2 weeks ago

peterduhon commented 2 weeks ago

Spike: Research LINK Token and VRF Coordinator on Morph Testnet

Ticket ID: SP-20 Type: Spike

Priority: High

Assignee: [fakename]

Objective

Research and document the availability and implementation details of LINK tokens and the VRF (Verifiable Random Function) coordinator on the Morph testnet.

Tasks

  1. Verify the existence of a LINK token contract on Morph testnet.
  2. Locate and document the address of the VRF coordinator on Morph testnet.
  3. Identify or set up faucets for obtaining test LINK tokens.
  4. Test the process of requesting randomness using Chainlink VRF on Morph testnet.
  5. Document any Morph-specific configurations or requirements for using Chainlink VRF.

Acceptance Criteria

Time Box

1-2 days

Outcome

The research from this spike will inform our implementation strategy for randomness generation in Skia Poker on the Morph testnet.

peterduhon commented 2 weeks ago

Here are the key details for integrating Chainlink VRF on the Morph testnet:

Morph Testnet VRF Configuration

Item Value
LINK Token 0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06[2]
VRF Coordinator 0x6A2AAd07396B36Fe02a22b33cf443582f682c82f[2][4]
Key Hash 0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314[4]
Fee 0.005 LINK[4]
Max Gas Limit 2,500,000[4]
Minimum Confirmations 3[4]
Maximum Confirmations 200[4]
Maximum Random Values 500[4]

Hi @tetyana-pol , pls update your poker game smart contract to work with Chainlink VRF on the Morph testnet:

  1. Update the constructor parameters:
constructor(
    address _vrfCoordinator,  // Use Morph testnet coordinator: 0x6A2AAd07396B36Fe02a22b33cf443582f682c82f 
    address _linkToken,       // Use Morph testnet LINK token: 0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06
    bytes32 _keyHash,         // Use Morph testnet key hash: 0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314
    uint256 _fee              // Use Morph testnet fee: 0.005 LINK
) VRFConsumerBase(_vrfCoordinator, _linkToken) {
    keyHash = _keyHash;
    fee = _fee;
    initializeDeck();
}
  1. Fund the contract with Morph testnet LINK tokens: The contract needs a balance of at least 0.005 testnet LINK per VRF request. Testnet LINK can be obtained from the official Chainlink faucet.[2]

  2. Deploy and test on the Morph testnet: Verify that VRF requests are fulfilled successfully. Monitor the RandomnessRequested and RandomnessFulfilled events.

  3. Handle any Morph-specific issues: Adjust the contract logic if needed to account for any differences or edge cases when using VRF on Morph compared to other networks.

  4. Document the integration process: Note any key findings or issues encountered to help with future development and debugging on the Morph testnet.

By updating these configuration details, funding the contract with testnet LINK, deploying to the Morph testnet, and thoroughly testing, you can adapt your poker game to leverage Chainlink VRF for secure randomness on the Morph Layer 2 solution.[1][3][5][6]

Cc: @tetyana-pol

Citations: [1] https://smartliquidity.info/2024/02/04/exploring-the-morph-testnet/ [2] https://web3.bitget.com/en/academy/what-is-morph [3] https://docs.chain.link/vrf/v1/supported-networks [4] https://docs.chain.link/vrf/v2/subscription/supported-networks [5] https://docs.chain.link/vrf/v2/direct-funding/supported-networks [6] https://boxmining.com/morph-token-airdrop-guide/

peterduhon commented 1 week ago

@CoolMan

I have the Morph testnet Chainlink VRF information now. Let's update the deployment process for the BettingAndPotManagement contract with these specific details:

  1. Update your deploy.js script to include these Morph-specific Chainlink VRF parameters:

const BettingAndPotManagement = await ethers.getContractFactory("BettingAndPotManagement");
const bettingAndPotManagement = await BettingAndPotManagement.deploy(
    roomId,                    // uint256 - Set this to a unique room identifier
    cardManagementAddress,     // address - Address of deployed CardManagement contract
    roomManagementAddress,     // address - Address of deployed RoomManagement contract
    userManagementAddress,     // address - Address of deployed UserManagement contract
    ethers.utils.parseEther("0.1"),  // uint256 - Example minimum bet of 0.1 ETH
    "0x6A2AAd07396B36Fe02a22b33cf443582f682c82f",  // address - Morph VRF Coordinator
    "0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06",  // address - Morph LINK Token
    "0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314",  // bytes32 - Morph VRF Key Hash
    ethers.utils.parseEther("0.005")  // uint256 - Morph VRF Fee (0.005 LINK)
);
JW-dev0505 commented 1 week ago

@nomea

Following your instructions, I successfully deployed BettingAndPotManagement contract. Here is updated code. Thank you!

const bettingAndPotManagement = await BettingAndPotManagement.deploy(
    roomId,                    // uint256 - Set this to a unique room identifier
    cardManagementAddress,     // address - Address of deployed CardManagement contract
    roomManagementAddress,     // address - Address of deployed RoomManagement contract
    userManagementAddress,     // address - Address of deployed UserManagement contract
    ethers.parseEther("0.1"),  // uint256 - Example minimum bet of 0.1 ETH
    "0x6A2AAd07396B36Fe02a22b33cf443582f682c82f",  // address - Morph VRF Coordinator
    "0x84b9B910527Ad5C03A9Ca831909E21e236EA7b06",  // address - Morph LINK Token
    "0xd4bb89654db74673a187bd804519e65e3f71a52bc55f11da7601a13dcf505314",  // bytes32 - Morph VRF Key Hash
    ethers.parseEther("0.005")  // uint256 - Morph VRF Fee (0.005 LINK)
);