2

I am following Patrick Collins Smart Contract Lottery development and trying to run the deploy script test net ( sepolia ) but I am getting this error

Error:

Failed to parse as type `uint256`: a character is not in the range 0-9

Snapshot:

enter image description here

The function which is called during deployment to Sepolia:

function getSepoliaEthConfig() public view returns (NetworkConfig memory sepoliaNetworkConfig) {
    sepoliaNetworkConfig = NetworkConfig({
        subscriptionId: 5613, // If left as 0, our scripts will create one!
        gasLane: 0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c,
        automationUpdateInterval: 30, // 30 seconds
        raffleEntranceFee: 0.01 ether,
        callbackGasLimit: 500000, // 500,000 gas
        vrfCoordinatorV2: 0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625,
        link: 0x779877A7B0D9E8603169DdbD7836e478b4624789,
        deployerKey: vm.envUint("PRIVATE_KEY")
    });
}

1 Answer 1

3

Try converting the value from hexadecimal to decimal format

cast --to-dec 0x1234567890ABcdeF

When working with Makefile you may get same error:

Failed to parse 4d5ef9****************************a38d7 as type uint256: a character is not in the range 0-9

For such case, add 0x to the PK in the .env file

4
  • What do you mean from hexa to dec? I have configured the private key in .env and this line is reading that deployerKey: vm.envUint("PRIVATE_KEY") but i can't resolve the erorr. Sep 30 at 8:43
  • wait a minute, @Alex it did work when i casted my PK to decimal and passed it in the function but what is going on :D can you please elaborate a little? TIA Sep 30 at 8:57
  • In this case, delete the first characters '0x' My .env entry looks like this: PRIVATE_KEY="9b7a..........................................................f9" Sep 30 at 8:57
  • Thanks a lot. Do we have any function or method which can directly cast this line PK to dec? vm.envUint("PRIVATE_KEY") Also I still didn't got when you mentioned delete characters '0x' bcz my PK don't have 0x at start. Sep 30 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.