Skip to content

I'm try deploy on rinkeby testnets its give me error that ValueError(f"'{value}' is not a valid ETH address") from None #103

@sam445uutg

Description

@sam445uutg

deploy.py
`from brownie import smart_lottery,config, network
from scripts.help_scripts import get_accounts, get_contract, fund_with_link
import time

def deploy_lottery():
account = get_accounts()
# usd=get_contract("eth_usd")
# vrfcoordinta =get_contract("VRFCoordinator")

smart_lottery.deploy(get_contract("eth_usd"),
                           get_contract("VRFCoordinator"),
                           get_contract('Link_Token') ,
                           config["networks"][network.show_active()]["fee"],
                           config["networks"][network.show_active()]["keyhash"],
                           {"from":account},
                           publish_source= config["networks"][network.show_active()].get("verfiy",False)
                           )
# print(usd, vrfcoordinta,)

def start__lottery():
account = get_accounts()
lottery = smart_lottery[-1]
start_lottery=lottery.start_lottery({"from":account})
start_lottery.wait(1)
print("lottery is started !!! \n welcome to lottery try your luck here??")

def enter_fee():
account = get_accounts()
lottery = smart_lottery[-1]
Values = lottery.getenterancefee()+100000000
enter_tx = lottery.enter({"from":account,"value":Values})
enter_tx.wait(1)
print("You paid fee")

def end_lottery():
account =get_accounts()
lottery= smart_lottery[-1]
#fund
tx= fund_with_link(lottery)
tx.wait(1)
end_lottery = lottery.end_lottery({"from":account})
end_lottery.wait(1)
time.sleep(60)
print(f"{lottery.winner()} is new winner")

def main():
deploy_lottery()
start__lottery()
enter_fee()
end_lottery()`

``brownie-config.yaml
networks:
default : development
development:
keyhash: '0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc'
fee: 1000000000
rinkeby:
eth_usd: '0x8A753747A1Fa494EC906cE90E9f37563A8AF630e'
VRFCoordinator: '0x6168499c0cFfCaCD319c818142124B7A15E857ab'
Link_Token: '0x01BE23585060835E02B77ef475b0Cc51aA1e0709'
keyhash: '0xd89b2bf150e3b9e13446986e571fb9cab24b13cea0a43ea20a6049a85cc807cc'
fee: 1000000000

mainnet-fork:
eth_usd: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419'
VRFCoordinator : '0x271682DEB8C4E0901D1a1550aD2e64D568E69909'
Link_Token: '0x271682DEB8C4E0901D1a1550aD2e64D568E69909'
keyhash: '0x8af398995b04c28e9951adb9721ef74c74f93e6a478f39e7e0777be13527e7ef'
fee: 1000000000

wallet:
from_key: ${PRIVATE_KEY}

smart-lottery-contract.sol
// SPDX-License-Identifier:MIT

pragma solidity <=0.8.0;

import "node_modules/@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
import "node_modules/@openzeppelin/contracts/access/Ownable.sol";
import "node_modules/@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

contract smart_lottery is VRFConsumerBase, Ownable{
// golbal variable
address payable[] public players;
uint256 public USD_amt;
address payable public winner;
AggregatorV3Interface internal ethusd_preice_feed;
uint256 public randomness;
enum LOTTERY_STATE {
CLOSED,
OPENED,
CALCULATING_WINNER
}
LOTTERY_STATE public lottery_state;
uint256 public fee;
bytes32 public keyHash;

constructor (address _pricefeed, address _vrfCoordinator ,address _link,uint256 _fee,bytes32 _keyHash) 
public VRFConsumerBase( _vrfCoordinator, _link){
    USD_amt= 5*(10**18);
    ethusd_preice_feed = AggregatorV3Interface(_pricefeed);
    lottery_state =LOTTERY_STATE.CLOSED;
    fee = _fee;
    keyHash = _keyHash;
}
function enter() public payable{
    //require(amt_usd );
    require(lottery_state == LOTTERY_STATE.OPENED);
    require(msg.value > getenterancefee(), "NOT ENOUGH ETH !!! NEXT TIME TRY>>>");
    players.push(payable(msg.sender));
} 
function getenterancefee() public view returns (uint256){
    (,int256 price,,,) = ethusd_preice_feed.latestRoundData();
    uint256 adjuest_price = uint256(price)* 10**10;
    uint256 cost_to_enter =((USD_amt*10**18) / adjuest_price);
    return cost_to_enter;
}
function start_lottery()public onlyOwner{
    require(lottery_state == LOTTERY_STATE.CLOSED,"Can't start  a new lottery yet");
    lottery_state = LOTTERY_STATE.OPENED;
}
function end_lottery() public onlyOwner{
    // uint(
    //     keccak256(
    //         abi.encodePacked(
    //             //nonce,
    //             msg.sender,
    //             block.difficulty,
    //             block.timestamp
    //         )
    //     )
    // )% players.length;
    lottery_state = LOTTERY_STATE.CALCULATING_WINNER;
    bytes32 requestId = requestRandomness(keyHash, fee);
}
function fulfillRandomness (bytes32 _requestId, uint256 _randomness) internal override{
    require(lottery_state == LOTTERY_STATE.CALCULATING_WINNER);
    require(randomness>0,"random-not-found");
    uint256 indexofwinner = randomness% players.length;
    winner = players[indexofwinner];
    winner.transfer(address(this).balance);
    //reset
    players = new address payable[](0);
    lottery_state =LOTTERY_STATE.CLOSED;
    randomness = _randomness;
}

}
I'm try deploy contract on development its running perfectly fine , but I'm try to deploy in rinkeby testnets its given me this error:
PS D:\Users\HP\code1.vscode\blockchain\demo\browine\lottery-smart-contract> brownie run scripts/deploy_lottery.py --network rinkeby
INFO: Could not find files for the given pattern(s).
Brownie v1.19.0 - Python development framework for Ethereum

LotterySmartContractProject is the active project.

Running 'scripts\deploy_lottery.py::main'...
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie_cli\run.py", line 51, in main
return_value, frame = run(
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\project\scripts.py", line 110, in run
return_value = f_locals[method_name](*args, **kwargs)
File ".\scripts\deploy_lottery.py", line 55, in main
deploy_lottery()
File ".\scripts\deploy_lottery.py", line 14, in deploy_lottery
smart_lottery.deploy(get_contract("eth_usd"),
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 542, in call
args, tx = _get_tx(None, args)
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\contract.py", line 1954, in _get_tx
tx["from"] = accounts.at(tx["from"], force=True)
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\account.py", line 244, in at
address = _resolve_address(address)
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\network\web3.py", line 195, in _resolve_address
return to_address(domain)
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\convert\main.py", line 43, in to_address
return str(EthAddress(value))
File "C:\Users\HP.local\pipx\venvs\eth-brownie\lib\site-packages\brownie\convert\datatypes.py", line 213, in new
raise ValueError(f"'{value}' is not a valid ETH address") from None
ValueError: '0x94870a14597c129b5b460401dc9ee87c053955fc0a89294ffa2b599dd198462a' is not a valid ETH address

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions