Solidity smart contract not working on local development network but working fine on goerli testnet #1870
-
I am new to learning solidity and python so please bear with me if you don't understand anything. you can find my project files here https://github.com/usmanfarooq91/nft-demo I am trying to create a demo NFT contract using solidity and python on VS code with brownie. everything works fine on testnet goerli but its giving me the following error when I run it on local development network. even on development network contract deployes successfully and gets funding in LINK tokens to request the requestRandomness() function as it requires a 0.1 LINK as fee to perform the task but when it calls the requestRandomness() function it gives the below error. I am using chainlink VRFcoordinator V1 so the nft can be assigned randomly. on github please refer to the advance_collectible.sol and deploy_and_create.py script in advance_collectible folder.
To my understanding I think there is a problem with development network settings but I can not figure it out. I have tried changing the keyhash and fee, I have also tried to fund the contract with more link tokens but it doesn't seem to work. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @usmanfarooq91 You have incorrect Correct this function in it as below: function onTokenTransfer(
address sender,
uint256 fee,
bytes memory _data
) public onlyLINK {
(bytes32 keyHash, uint256 seed) = abi.decode(_data, (bytes32, uint256));
emit RandomnessRequest(sender, keyHash, seed);
} You are just missing |
Beta Was this translation helpful? Give feedback.
Hello @usmanfarooq91
You have incorrect
VRFCoordinatorMock.sol
contract implemented under your contracts/test folder.Correct this function in it as below:
You are just missing
uint256 fee
there currently and rest of your code is correct and this will work. Not sure how could you get this contract incorrectly tho as you should copy it from repo and don't touch it :p