Thanks in advance for getting here and trying to see my bad code.
So, I have some trouble on trying to "sell" tickets to people and give them the possibility to buy >=1.
Now, the problem, is that i can't associate an array of 6 numbers to the ticket.
What is wrong? Thanks!
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol";
contract Lottery is Ownable {
uint256 constant ticketprice = 1 ether;
address pool = addresshere;
uint ID = 0;
uint256 startinglottery;
struct Picket {
uint ID;
uint[6] ticket;
}
mapping (address => Picket) hope;
address[] players;
constructor() {
startinglottery = 0;
}
function StartLottery() public onlyOwner {
startinglottery = 1;
}
function EndLottery() public onlyOwner {
startinglottery = 0;
}
function BuyTicket(address _address) public payable {
//check
require(msg.value >= ticketprice, "not enought money!");
require(startinglottery == 1, "lottery isn't started.");
//pay
payable(pool).transfer(msg.value);
//do stuff
Picket memory picket = hope[_address];
picket.ID = ID;
picket.ticket = [1,2,3,4,5]; //should be random with chainlink, but trying to understand the basic one.
players.push(_address);
ID++;
}
function getTicket(address _address) public view returns(uint, uint[6] memory) {
return (hope[_address].ID, hope[_address].ticket);
}
}